51 lines
1023 B
Lua
51 lines
1023 B
Lua
function stateMenu()
|
|
local selected = 1
|
|
|
|
function onBtnDraw(btn)
|
|
if selected == btn.data.i then
|
|
btn.color = 7
|
|
end
|
|
end
|
|
|
|
local buttons = {
|
|
makeButton({x=10, y=10, w=30, text="play", data={i=1},
|
|
onClick=function() setState(states.game) end,
|
|
onHover=function(btn) btn.color = 7 selected = 1 end,
|
|
onDraw=onBtnDraw}),
|
|
makeButton({x=10, y=20, w=30, text="rules", data={i=2},
|
|
onClick=function() setState(states.rules) end,
|
|
onHover=function(btn) btn.color = 7 selected = 2 end,
|
|
onDraw=onBtnDraw})
|
|
}
|
|
|
|
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]:onClick()
|
|
end
|
|
selected = mid(1, selected, #buttons)
|
|
|
|
end,
|
|
|
|
_draw = function()
|
|
for k,button in ipairs(buttons) do
|
|
button:draw(selected == k)
|
|
end
|
|
print("press 🅾️/c to continue", 8, 120, 7)
|
|
end
|
|
}
|
|
end |