pico8-0hh1/states/rules.lua

94 lines
1.8 KiB
Lua

function state_rules()
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 go_back()
set_state(states.menu)
end
local btn_back = make_button({x=1, y=118, w=30, h=7, text="🅾️/C mENU", color=8,
on_click=function() go_back() end,
on_hover=function(btn) btn.color = 7 end})
return {
_enter = function()
custom_font()
end,
_exit = function()
standard_font()
end,
_update=function()
if frame_count%8==0 then
color += 1
end
if color>#fade then
color = 1
end
-- Back to the menu
if btnp(BTN_X) then
go_back()
end
btn_back:update()
end,
_draw=function()
cls()
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)
--------------
btn_back:draw()
end,
}
end