Simple UI library for LÖVE framework.
- simple setup
- written in functional manner, no global state
- hierarchical structure as input
- compact syntax
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.
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