Keyboard navigration + start of rules

This commit is contained in:
2022-05-29 22:55:43 +02:00
parent f793c3e17a
commit 7a293234c9
5 changed files with 77 additions and 11 deletions
+12 -1
View File
@@ -1,6 +1,5 @@
function stateMenu()
local items = {"play", "rules"}
local selected = 1
local buttons = {
makeButton(10, 10, 30, 6, "play",
@@ -17,16 +16,28 @@ function stateMenu()
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
+12
View File
@@ -0,0 +1,12 @@
function stateRules()
return {
_update=function()
end,
_draw=function()
print("1) you can't have more than\n 2 tiles of the same color\n in a row.", 2,2, 7)
sspr(0,32, 12,12, 8,24)
spr(2, 23, 25)
sspr(12,32, 12,12, 34,24)
end,
}
end