Skip to content

k-bk/love2d-ui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

love2d-ui love2d version

Simple UI library for LÖVE framework.

Features:

  • simple setup
  • written in functional manner, no global state
  • hierarchical structure as input
  • compact syntax

Run the demo

Library is the UI.lua file.

Demo code is inside main.lua file.

Linux: Type make inside cloned repo to test the capabilities of the library.

Usages:

Example

local UI = require "UI"

function love.load ()
   -- Set up variables used as labels (note the curly brackets)
   explosives = {15}
   boom = "Not loaded"

   -- Set up functions for buttons
   function loadCannon () 
      boom = "Loaded" 
   end
   function setFire ()
      if boom == "Loaded" then 
         boom = "BOOM!" 
      end
   end
end

function love.draw ()
   UI.draw {
      UI.label { "Select amount of explosives" },
      UI.slider { explosives, range = { 0,100 } },
      {  
         UI.button { "Load explosives", on_click = loadCannon }, 
         UI.button { "Set fire", on_click = setFire },
      },
      UI.label { boom },
   }
end

Example of UI

Written in Lua using awesome love2d framework.