pico8-0hh1/states/rules.lua

87 lines
1.7 KiB
Lua
Raw Normal View History

2022-06-02 20:18:02 +02:00
function state_rules()
2022-05-30 22:44:22 +02:00
2022-06-01 21:26:57 +02:00
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"
2022-05-30 22:44:22 +02:00
local color = 1
2022-06-01 23:14:22 +02:00
local function blink(x,y,w,h)
2022-05-30 22:44:22 +02:00
rect2(x,y,w,h,fade[color])
end
2022-06-02 20:18:02 +02:00
local function go_back()
set_state(states.menu)
2022-06-01 21:26:57 +02:00
end
2022-06-02 20:18:02 +02:00
local btn_back = make_button({x=1, y=118, w=30, h=7, text="❎menu", color=8,
on_click=function() go_back() end,
on_hover=function(btn) btn.color = 7 end})
2022-05-30 22:44:22 +02:00
return {
_update=function()
2022-06-02 20:18:02 +02:00
if frame_count%8==0 then
2022-05-30 22:44:22 +02:00
color += 1
end
if color>#fade then
color = 1
end
2022-06-01 21:26:57 +02:00
-- Back to the menu
if btnp(BTN_X) then
2022-06-02 20:18:02 +02:00
go_back()
2022-06-01 21:26:57 +02:00
end
2022-06-02 20:18:02 +02:00
btn_back:update()
2022-05-30 22:44:22 +02:00
end,
_draw=function()
2022-07-02 13:52:31 +02:00
cls()
2022-06-02 20:18:02 +02:00
custom_font()
2022-06-01 21:26:57 +02:00
2022-05-30 22:44:22 +02:00
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)
2022-06-01 21:26:57 +02:00
--------------
2022-06-02 20:18:02 +02:00
btn_back:draw()
2022-05-30 22:44:22 +02:00
end,
}
2022-05-29 22:55:43 +02:00
end