fortunes_foundation/state_gameround.lua

42 lines
1.0 KiB
Lua
Raw Normal View History

2024-02-11 01:44:38 +00:00
state_gameround=klass()
2024-02-11 03:42:38 +00:00
function state_gameround:init(watcher,ruleset)
self.board=board:new(watcher,ruleset)
2024-02-11 06:01:05 +00:00
self.outcome=nil
2024-02-11 05:41:48 +00:00
self.restart_frames=0
2024-02-11 01:44:38 +00:00
end
function state_gameround:enter() end
function state_gameround:exit() end
function state_gameround:reenter() end
2024-02-11 03:42:38 +00:00
function state_gameround:suspend() end
2024-02-11 01:44:38 +00:00
function state_gameround:update()
self.board:update()
2024-02-11 05:41:48 +00:00
if btn(5) then
self.restart_frames+=1
else
self.restart_frames=0
end
local restart_progress=self.restart_frames/60
self.board:set_restart_progress(restart_progress)
2024-02-11 06:01:05 +00:00
if restart_progress>=1.0 then
main.state_manager:push(state_restartmenu:new())
return
end
2024-02-11 01:44:38 +00:00
if self.board:can_take_input() then
if (btnp(0)) self.board.cursor:move_x(-1)
if (btnp(1)) self.board.cursor:move_x(1)
if (btnp(2)) self.board.cursor:move_y(-1)
if (btnp(3)) self.board.cursor:move_y(1)
if (btnp(4)) self.board.cursor:toggle_grab()
if (btnp(5)) self.board:undo()
end
2024-02-11 06:01:05 +00:00
if (self.board:is_won()) self.outcome="win" self.done=true
2024-02-11 01:44:38 +00:00
end
function state_gameround:draw()
cls(13)
self.board:draw()
end