From b669f9d55e7efc8521b531138b16d2a70ad28177 Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Sat, 24 Sep 2022 15:22:18 +0200 Subject: [PATCH] stuff --- .gitignore | 2 ++ coroutines.lua | 32 ++++++++++++++++---------------- globals.lua | 5 +++-- states/endgame.lua | 8 ++++---- visuals.lua | 5 ++--- 5 files changed, 27 insertions(+), 25 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9029ef1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +game.js +game.html diff --git a/coroutines.lua b/coroutines.lua index 6292139..a0e41d7 100644 --- a/coroutines.lua +++ b/coroutines.lua @@ -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 \ No newline at end of file diff --git a/globals.lua b/globals.lua index 6aa53ae..830003f 100644 --- a/globals.lua +++ b/globals.lua @@ -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, diff --git a/states/endgame.lua b/states/endgame.lua index 064c4d0..55c8956 100644 --- a/states/endgame.lua +++ b/states/endgame.lua @@ -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 diff --git a/visuals.lua b/visuals.lua index 3153256..7abd1a9 100644 --- a/visuals.lua +++ b/visuals.lua @@ -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