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

View File

@ -6,14 +6,15 @@ local mouse_y = 0
-- constants
--
local BLUE = 1
local YELLOW = 2
local BLUE = 2
local YELLOW = 1
-- 🅾️ Z[C]N ❎ [X]VM
-- 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 patterns = {
0b0000000000000000,
0b1000000000000000,
0b1000000000100000,
0b1010000000100000,

View File

@ -3,14 +3,14 @@ function state_endgame()
local message = "웃웃 yay! 웃웃"
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()
set_state(states.menu)
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)
board = _board
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)
local p = #patterns
printh(patterns)
local from_color = get_main_color(from_tint)
local to_color = get_main_color(to_tint)
add(overlays, {
_draw = function(self)
fillp()
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)
p -= 2
p -= 1
if p < 1 then
del(overlays, self)
end