Blinking rules

This commit is contained in:
Simon Cambier 2022-05-30 22:44:22 +02:00
parent 7a293234c9
commit d1946315e9
3 changed files with 87 additions and 22 deletions

21
0hh1.p8
View File

@ -1,6 +1,11 @@
pico-8 cartridge // http://www.pico-8.com pico-8 cartridge // http://www.pico-8.com
version 36 version 36
__lua__ __lua__
-- Font M3X6 by daniel linssen
poke(0x5600, 4, 4, 7)
poke4(0x5700,unpack(split"0x0000.0000,0x0000.0000,0x0202.0202,0x0000.0200,0x0000.0505,0x0000.0000,0x0505.0705,0x0000.0507,0x0407.0106,0x0000.0203,0x0204.0100,0x0000.0401,0x0102.0502,0x0000.0305,0x0000.0102,0x0000.0000,0x0101.0102,0x0000.0201,0x0202.0201,0x0000.0102,0x0205.0000,0x0000.0005,0x0702.0000,0x0000.0002,0x0000.0000,0x0000.0102,0x0700.0000,0x0000.0000,0x0000.0000,0x0000.0200,0x0202.0404,0x0000.0101,0x0505.0506,0x0000.0305,0x0202.0302,0x0000.0702,0x0204.0403,0x0000.0701,0x0403.0403,0x0000.0304,0x0406.0505,0x0000.0404,0x0403.0107,0x0000.0304,0x0503.0106,0x0000.0605,0x0204.0407,0x0000.0202,0x0502.0506,0x0000.0305,0x0605.0503,0x0000.0304,0x0002.0000,0x0000.0002,0x0002.0000,0x0000.0102,0x0102.0400,0x0000.0402,0x0007.0000,0x0000.0007,0x0402.0100,0x0000.0102,0x0204.0403,0x0000.0200,0x0505.0506,0x0000.0601,0x0604.0300,0x0000.0705,0x0505.0301,0x0000.0705,0x0101.0600,0x0000.0701,0x0505.0604,0x0000.0705,0x0705.0600,0x0000.0601,0x0702.0204,0x0000.0202,0x0705.0600,0x0000.0304,0x0505.0301,0x0000.0505,0x0202.0002,0x0000.0202,0x0202.0002,0x0000.0102,0x0305.0101,0x0000.0505,0x0202.0202,0x0000.0402,0x0707.0300,0x0000.0507,0x0505.0300,0x0000.0505,0x0505.0600,0x0000.0305,0x0305.0700,0x0000.0101,0x0705.0600,0x0000.0404,0x0101.0600,0x0000.0101,0x0701.0600,0x0000.0304,0x0207.0202,0x0000.0202,0x0505.0500,0x0000.0705,0x0505.0500,0x0000.0205,0x0705.0500,0x0000.0507,0x0205.0500,0x0000.0505,0x0605.0500,0x0000.0304,0x0204.0700,0x0000.0701,0x0101.0103,0x0000.0301,0x0202.0101,0x0000.0404,0x0202.0203,0x0000.0302,0x0000.0502,0x0000.0000,0x0000.0000,0x0000.0403,0x0000.0201,0x0000.0000,0x0507.0506,0x0000.0505,0x0507.0503,0x0000.0705,0x0101.0106,0x0000.0701,0x0505.0503,0x0000.0305,0x0103.0107,0x0000.0701,0x0301.0106,0x0000.0101,0x0501.0106,0x0000.0705,0x0507.0505,0x0000.0505,0x0202.0207,0x0000.0702,0x0404.0407,0x0000.0304,0x0503.0505,0x0000.0505,0x0101.0101,0x0000.0701,0x0507.0705,0x0000.0505,0x0505.0503,0x0000.0505,0x0505.0506,0x0000.0305,0x0103.0507,0x0000.0101,0x0505.0506,0x0000.0403,0x0503.0507,0x0000.0505,0x0407.0106,0x0000.0304,0x0202.0207,0x0000.0202,0x0505.0505,0x0000.0705,0x0505.0505,0x0000.0205,0x0705.0505,0x0000.0507,0x0202.0505,0x0000.0505,0x0205.0505,0x0000.0202,0x0202.0407,0x0000.0701,0x0302.0204,0x0000.0402,0x0202.0202,0x0000.0202,0x0602.0201,0x0000.0102,0x0704.0000,0x0000.0001,0x0205.0200,0x0000.0000"))
poke(0x5f58,0x81)
#include main.lua #include main.lua
#include board.lua #include board.lua
#include states/menu.lua #include states/menu.lua
@ -40,14 +45,14 @@ __gfx__
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
11011011011001101101101100110110110110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 cc0cc01101100cc0cc088011001101101101100110110110110011011011011008801101101100880880cc01100880880cc01100000000000000000000000000
11011011011001101101101100110110110110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 cc0cc01101100cc0cc088011001101101101100110110110110011011011011008801101101100880880cc01100880880cc01100000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
cc0cc01101100cc0cc08801100cc0cc0880110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 1101101101100110110110110011011088011001101108801100880880cc01100880880cc0cc00cc0880cc08800cc0880cc08800000000000000000000000000
cc0cc01101100cc0cc08801100cc0cc0880110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 1101101101100110110110110011011088011001101108801100880880cc01100880880cc0cc00cc0880cc08800cc0880cc08800000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
11011011011001101101101100110110cc0110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 110110110110011011011011001101101101100110110cc01100cc01101101100cc01101101100110cc08801100cc0cc08808800000000000000000000000000
11011011011001101101101100110110cc0110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 110110110110011011011011001101101101100110110cc01100cc01101101100cc01101101100110cc08801100cc0cc08808800000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
11011088011001101108801100110110880110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 110cc0cc01100880cc0cc0880011011088011001101108801100cc01101101100cc01101101100110cc0880cc00880cc0880cc00000000000000000000000000
11011088011001101108801100110110880110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 110cc0cc01100880cc0cc0880011011088011001101108801100cc01101101100cc01101101100110cc0880cc00880cc0880cc00000000000000000000000000

View File

@ -52,9 +52,12 @@ function slice(tbl, first, last, step)
return sliced return sliced
end end
local _rectfill = rectfill function rectfill2(x, y, w, h, col)
function rectfill(x, y, w, h, col) rectfill(x, y, x+w, y+h, col)
_rectfill(x, y, x+w, y+h, col) end
function rect2(x, y, w, h, col)
rect(x, y, x+w, y+h, col)
end end
-- --
@ -120,7 +123,7 @@ function makeButton(x, y, w, h, text, onClick, onHover)
onHover = onHover, onHover = onHover,
draw=function(self, selected) draw=function(self, selected)
-- rectfill(self.x, self.y, self.w, self.h, 8) -- rectfillw(self.x, self.y, self.w, self.h, 8)
local color = selected and 7 or 5 local color = selected and 7 or 5
print(self.text, self.x+1, self.y+1, color) print(self.text, self.x+1, self.y+1, color)
end, end,
@ -164,6 +167,8 @@ function _init()
mouse_x = 0 mouse_x = 0
mouse_y = 0 mouse_y = 0
frameCount = 0
states = { states = {
rules = stateRules(), rules = stateRules(),
menu = stateMenu(), menu = stateMenu(),
@ -175,6 +180,7 @@ function _init()
end end
function _update60() function _update60()
frameCount += 1
gs._update() gs._update()
-- if not create then -- if not create then
-- board:solveStep() -- board:solveStep()

View File

@ -1,12 +1,66 @@
function stateRules() function stateRules()
return {
_update=function() local fade = split"0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,4,9,10,9,4,2"
end, local color = 1
_draw=function()
print("1) you can't have more than\n 2 tiles of the same color\n in a row.", 2,2, 7) function blink(x,y,w,h)
sspr(0,32, 12,12, 8,24) rect2(x,y,w,h,fade[color])
spr(2, 23, 25) end
sspr(12,32, 12,12, 34,24)
end,
} return {
_update=function()
if frameCount%8==0 then
color += 1
end
if color>#fade then
color = 1
end
end,
_draw=function()
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)
end,
}
end end