pico8-0hh1/states/rules.lua

86 lines
1.7 KiB
Lua

function stateRules()
local fade = split"0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,4,9,10,9,4,2,1"
local color = 1
local function blink(x,y,w,h)
rect2(x,y,w,h,fade[color])
end
local function goBack()
setState(states.menu)
end
local btnBack = makeButton({x=1, y=118, w=30, h=7, text="❎ mENU", color=8,
onClick=function() goBack() end,
onHover=function(btn) btn.color = 7 end})
return {
_update=function()
if frameCount%8==0 then
color += 1
end
if color>#fade then
color = 1
end
-- Back to the menu
if btnp(BTN_X) then
goBack()
end
btnBack:update()
end,
_draw=function()
customFont()
print("1) yOU CAN'T HAVE MORE THAN\n TWO (2) CONSECUTIVE TILES\n OF THE SAME COLOR", 2,2, 7)
local x = 14
local y = 28
sspr(0,32, 12,12, x,y)
spr(2, x+14, y+1)
sspr(13,32, 12,12, x+26,y)
blink(x-1, y-1, 9, 3)
blink(x+25, y-1, 9, 3)
blink(x-1, y+8, 12, 3)
blink(x+25, y+8, 12, 3)
x = 75
sspr(26,32, 12,12, x,y)
spr(2, x+14, y+1)
sspr(39,32, 12,12, x+26,y)
blink(x+5, y+2, 3, 9)
blink(x+31, y+2, 3, 9)
--------------
x = 44
y = 50
print("2) eACH LINE CONTAINS AN EQUAL\n NUMBER OF EACH COLOR", 2, y, 7)
sspr(52,32, 12,12, x,y+20)
spr(2, x+14, y+21)
sspr(65,32, 12,12, x+26,y+20)
blink(x+5, y+22, 6, 3)
blink(x+31, y+22, 6, 3)
blink(x-1, y+19, 3, 6)
blink(x+25, y+19, 3, 6)
--------------
x = 44
y = 90
print("3) aLL ROWS AND COLUMNS\n ARE DIFFERENT", 2, y, 7)
sspr(78,32, 12,12, x,y+20)
spr(2, x+14, y+21)
sspr(91,32, 12,12, x+26,y+20)
blink(x-1, y+25, 12, 6)
blink(x+25, y+25, 12, 6)
--------------
btnBack:draw()
end,
}
end