Restart level animation
This commit is contained in:
parent
b4f4b8cbb5
commit
8b23695945
@ -9,6 +9,7 @@ function board:init(w)
|
||||
self.checkpoint=nil
|
||||
self.slots={}
|
||||
self.wells={}
|
||||
self.restart_progress=0
|
||||
|
||||
-- board slots
|
||||
-- ...n_slots: normal
|
||||
@ -68,6 +69,10 @@ function board:deal(seed)
|
||||
end
|
||||
end
|
||||
|
||||
function board:set_restart_progress(progress)
|
||||
self.restart_progress=progress
|
||||
end
|
||||
|
||||
function board:undo()
|
||||
if (not self.watcher:intercept("undo")) return
|
||||
if (self.checkpoint) self.checkpoint:apply(self)
|
||||
@ -177,6 +182,8 @@ function board:draw()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
democrap:distort_screen(self.restart_progress)
|
||||
end
|
||||
|
||||
slot=klass()
|
||||
|
35
democrap.lua
Normal file
35
democrap.lua
Normal 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
|
1
main.p8
1
main.p8
@ -7,6 +7,7 @@ __lua__
|
||||
#include board_animations.lua
|
||||
#include checkpoint.lua
|
||||
#include dealer.lua
|
||||
#include democrap.lua
|
||||
#include cursor.lua
|
||||
#include layout.lua
|
||||
#include layout_hint.lua
|
||||
|
@ -1,6 +1,7 @@
|
||||
state_gameround=klass()
|
||||
function state_gameround:init(watcher,ruleset)
|
||||
self.board=board:new(watcher,ruleset)
|
||||
self.restart_frames=0
|
||||
end
|
||||
function state_gameround:enter() end
|
||||
function state_gameround:exit() end
|
||||
@ -10,6 +11,13 @@ function state_gameround:suspend() end
|
||||
|
||||
function state_gameround: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 (btnp(0)) self.board.cursor:move_x(-1)
|
||||
if (btnp(1)) self.board.cursor:move_x(1)
|
||||
|
@ -1,4 +1,5 @@
|
||||
tutorial={
|
||||
function() return watcher:new(progression[6]) end,
|
||||
function()
|
||||
return watcher:new(progression[1], 10,{
|
||||
tutorial_grab:new(1,4),
|
||||
|
Loading…
Reference in New Issue
Block a user