This commit is contained in:
Simon Cambier 2022-09-24 15:22:18 +02:00
parent 57409bb7d6
commit b669f9d55e
5 changed files with 27 additions and 25 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
game.js
game.html

View File

@ -1,34 +1,34 @@
local coroutines={} local coroutines={}
-- starts a coroutine and saves it for future reference -- starts a coroutine and saves it for future reference
function startcoroutine(fn) function startcoroutine(co)
assert(tostr(fn) == "[thread]") -- make sure that fn is a coroutine, the return value of cocreate() assert(tostr(co) == "[thread]") -- make sure that co is a coroutine, the return value of cocreate()
add(coroutines, fn) add(coroutines, co)
end end
-- stops the the coroutine -- stops the the coroutine
function stopcoroutine(fn) function stopcoroutine(co)
del(coroutines, fn) del(coroutines, co)
end end
function _coresolve() function _coresolve()
for co in all(coroutines) do for co in all(coroutines) do
if costatus(co)!='dead' then if costatus(co) != 'dead' then
assert(coresume(co)) assert(coresume(co))
else else
stopcoroutine(co) stopcoroutine(co)
end end
end end
end end
-- to be used inside a coroutine -- to be used inside a coroutine
function wait(seconds) function wait(seconds)
wait_frames(seconds*30) wait_frames(seconds*30)
end end
-- to be used inside a coroutine -- to be used inside a coroutine
function wait_frames(frames) function wait_frames(frames)
for i=1,frames do for i=1,frames do
yield() yield()
end end
end end

View File

@ -6,14 +6,15 @@ local mouse_y = 0
-- constants -- constants
-- --
local BLUE = 1 local BLUE = 2
local YELLOW = 2 local YELLOW = 1
-- 🅾️ Z[C]N ❎ [X]VM -- 🅾️ Z[C]N ❎ [X]VM
-- X and C have the same position on QWERTY and AZERTY -- X and C have the same position on QWERTY and AZERTY
local LEFT,RIGHT,UP,DOWN,BTN_O,BTN_X = 0,1,2,3,4,5 local LEFT,RIGHT,UP,DOWN,BTN_O,BTN_X = 0,1,2,3,4,5
local patterns = { local patterns = {
0b0000000000000000,
0b1000000000000000, 0b1000000000000000,
0b1000000000100000, 0b1000000000100000,
0b1010000000100000, 0b1010000000100000,

View File

@ -3,14 +3,14 @@ function state_endgame()
local message = "웃웃 yay! 웃웃" local message = "웃웃 yay! 웃웃"
local message_x = 0 local message_x = 0
local btn_back = make_button({x=1, y=118, h=7, text="🅾️/C bACK TO mENU", color=8,
on_click=function() go_to_menu() end,
on_hover=function(btn) btn.color = 7 end})
local function go_to_menu() local function go_to_menu()
set_state(states.menu) set_state(states.menu)
end end
local btn_back = make_button({x=1, y=118, h=7, text="🅾️/C bACK TO mENU", color=8,
on_click=function() go_to_menu() end,
on_hover=function(btn) btn.color = 7 end})
local function _enter(_board) local function _enter(_board)
board = _board board = _board
message_x = (128 - print(message,0,-100))/2 message_x = (128 - print(message,0,-100))/2

View File

@ -22,16 +22,15 @@ end
function spawn_tile_transition(x, y, w, h, from_tint, to_tint) function spawn_tile_transition(x, y, w, h, from_tint, to_tint)
local p = #patterns local p = #patterns
printh(patterns)
local from_color = get_main_color(from_tint) local from_color = get_main_color(from_tint)
local to_color = get_main_color(to_tint) local to_color = get_main_color(to_tint)
add(overlays, { add(overlays, {
_draw = function(self) _draw = function(self)
fillp() fillp()
rectfill(x, y, x + w, y + h, from_color) rectfill(x, y, x + w, y + h, from_color)
fillp(patterns[p]+0b0.1) fillp(patterns[p\1]+0b0.1)
rectfill(x, y, x + w, y + h, to_color) rectfill(x, y, x + w, y + h, to_color)
p -= 2 p -= 1
if p < 1 then if p < 1 then
del(overlays, self) del(overlays, self)
end end