Restart level animation

This commit is contained in:
Pyrex 2024-02-10 21:41:48 -08:00
parent b4f4b8cbb5
commit 8b23695945
5 changed files with 52 additions and 0 deletions

View File

@ -9,6 +9,7 @@ function board:init(w)
self.checkpoint=nil self.checkpoint=nil
self.slots={} self.slots={}
self.wells={} self.wells={}
self.restart_progress=0
-- board slots -- board slots
-- ...n_slots: normal -- ...n_slots: normal
@ -68,6 +69,10 @@ function board:deal(seed)
end end
end end
function board:set_restart_progress(progress)
self.restart_progress=progress
end
function board:undo() function board:undo()
if (not self.watcher:intercept("undo")) return if (not self.watcher:intercept("undo")) return
if (self.checkpoint) self.checkpoint:apply(self) if (self.checkpoint) self.checkpoint:apply(self)
@ -177,6 +182,8 @@ function board:draw()
end end
end) end)
end end
democrap:distort_screen(self.restart_progress)
end end
slot=klass() slot=klass()

35
democrap.lua Normal file
View File

@ -0,0 +1,35 @@
democrap={
patterns={
0b1111111111111111,
0b1111111111111111,
0b1111111111111111,
0b1111111111111111,
0b1111111111111111,
0b1111111111111111,
0b1111111111111111,
0b1111111111111100,
0b1111111111110000,
0b1111110011110000,
0b1111000011110000,
0b1111000011000000,
0b1111000000000000,
0b1100000000000000,
0b0000000000000000
}
}
function democrap:distort_screen(progress)
if (progress <= 0) return
progress=min(progress,1)
for src=0x6002,0x7fc2,64 do
dst=src+sin(t()+src/0x800)*(4*progress)+0.5
memcpy(dst,src,60)
end
local ps=democrap.patterns
local p=ps[1+flr(progress*#ps)] or ps[#ps]
fillp(p)
local old=@0x5333
poke(0x5f33,1)
rectfill(0,0,127,127,13)
poke(0x5f33,old)
fillp()
end

View File

@ -7,6 +7,7 @@ __lua__
#include board_animations.lua #include board_animations.lua
#include checkpoint.lua #include checkpoint.lua
#include dealer.lua #include dealer.lua
#include democrap.lua
#include cursor.lua #include cursor.lua
#include layout.lua #include layout.lua
#include layout_hint.lua #include layout_hint.lua

View File

@ -1,6 +1,7 @@
state_gameround=klass() state_gameround=klass()
function state_gameround:init(watcher,ruleset) function state_gameround:init(watcher,ruleset)
self.board=board:new(watcher,ruleset) self.board=board:new(watcher,ruleset)
self.restart_frames=0
end end
function state_gameround:enter() end function state_gameround:enter() end
function state_gameround:exit() end function state_gameround:exit() end
@ -10,6 +11,13 @@ function state_gameround:suspend() end
function state_gameround:update() function state_gameround:update()
self.board:update() self.board:update()
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)
if self.board:can_take_input() then if self.board:can_take_input() then
if (btnp(0)) self.board.cursor:move_x(-1) if (btnp(0)) self.board.cursor:move_x(-1)
if (btnp(1)) self.board.cursor:move_x(1) if (btnp(1)) self.board.cursor:move_x(1)

View File

@ -1,4 +1,5 @@
tutorial={ tutorial={
function() return watcher:new(progression[6]) end,
function() function()
return watcher:new(progression[1], 10,{ return watcher:new(progression[1], 10,{
tutorial_grab:new(1,4), tutorial_grab:new(1,4),