52 lines
1.0 KiB
Lua
52 lines
1.0 KiB
Lua
function state_menu()
|
|
local selected = 1
|
|
|
|
local function on_btn_draw(btn)
|
|
if selected == btn.data.i then
|
|
btn.color = 7
|
|
end
|
|
end
|
|
|
|
local buttons = {
|
|
make_button({x=10, y=10, w=30, text="play", data={i=1},
|
|
on_click=function() set_state(states.loading) end,
|
|
on_hover=function(btn) btn.color = 7 selected = 1 end,
|
|
on_draw=on_btn_draw}),
|
|
make_button({x=10, y=20, w=30, text="rules", data={i=2},
|
|
on_click=function() set_state(states.rules) end,
|
|
on_hover=function(btn) btn.color = 7 selected = 2 end,
|
|
on_draw=on_btn_draw})
|
|
}
|
|
|
|
local function _enter()
|
|
|
|
end
|
|
|
|
return {
|
|
_enter = _enter,
|
|
|
|
_update = function()
|
|
for button in all(buttons) do
|
|
button:update()
|
|
end
|
|
|
|
if btnp(UP) then
|
|
selected -= 1
|
|
elseif btnp(DOWN) then
|
|
selected += 1
|
|
elseif btnp(BTN_O) then
|
|
buttons[selected]:on_click()
|
|
end
|
|
selected = mid(1, selected, #buttons)
|
|
|
|
end,
|
|
|
|
_draw = function()
|
|
cls()
|
|
for k,button in ipairs(buttons) do
|
|
button:draw(selected == k)
|
|
end
|
|
print("press 🅾️/c to continue", 8, 120, 7)
|
|
end
|
|
}
|
|
end |