Chameleon FX to restart the level

This commit is contained in:
Pyrex 2022-12-17 16:25:20 -08:00
parent d0eba82c7b
commit 99744a31d6

View File

@ -135,6 +135,10 @@ function level:reinit(n)
self:spawn_exit() self:spawn_exit()
end end
function level:restart()
self:reinit(self.ix)
end
function level:advance() function level:advance()
self:reinit(self.ix+1) self:reinit(self.ix+1)
end end
@ -471,6 +475,10 @@ add(modules,player)
function player:init() function player:init()
--self:reinit(8,14) --self:reinit(8,14)
-- don't change this on reinit:
-- it stays the same when the level is changed or reloaded
self.vanish_frame=0
end end
function player:reinit(x,y) function player:reinit(x,y)
@ -481,6 +489,7 @@ function player:reinit(x,y)
self.todo={} self.todo={}
self.fall_frame=0 self.fall_frame=0
self.reset_frame=0
self.orientx=-1 self.orientx=-1
self.orienty=0 self.orienty=0
@ -509,6 +518,10 @@ function player:update()
return xs return xs
end end
-- this is a non-gameplay action that takes precedence over
-- all gameplay actions
self:_vanish_if_requested()
if not self:any_busy() then if not self:any_busy() then
if level:win_at(self.x,self.y) then if level:win_at(self.x,self.y) then
level:advance() level:advance()
@ -584,10 +597,31 @@ function player:update()
end end
end end
function player:_fall() function player:_vanish_if_requested()
if self.fall_frame<10 then local bvan=btn(❎)
self.fall_frame+=1 if self.bvan and not bvan then
self.vanishing=false
elseif not self.bvan and bvan then
self.vanishing=true
end end
self.bvan=bvan
if self.vanishing then
self.vanish_frame+=1
if (self.fall_frame>10 or self.vanish_frame>20) then
level:restart()
self.vanishing=false
end
else
self.vanish_frame-=1
end
self.vanish_frame=max(self.vanish_frame,0)
end
function player:_fall()
if (self.fall_frame<10) self.fall_frame+=1
end end
function player:_rope_pos() function player:_rope_pos()
@ -609,20 +643,37 @@ function player:draw()
local head=2-self.orienty local head=2-self.orienty
if (self.fall_frame>5) return local vanish_level=self.vanish_frame/20
local invis_level=max(self.fall_frame/10,4*(vanish_level-0.75))
if (invis_level>=1.0) return
if (self.fall_frame>0) then --px+=sin(vanish_level*16)*max(vanish_level-0.1,0)*1
-- base colors
pal(13,14)
pal(15,14)
pal(5,12)
pal(4,12)
pal(2,3)
-- vanish colors
local vanish=split"13,15,14,5,4,12,2,3,9,10"
for i,ilc in ipairs(vanish) do
if (vanish_level>i/#vanish) pal(ilc,1)
end
if self.fall_frame>3 then
for i=0,15 do pal(i,1) end for i=0,15 do pal(i,1) end
end end
if self.orientx==-1 then if self.orientx==-1 then
spr(16,px+6,py-2,1,1) spr(16,px+6,py-2,1,1)
if (self.rope and self.fall_frame==0) self.rope:draw() if (self.rope and invis_level<=0.25) self.rope:draw()
spr(17,px+1,py,1,1) spr(17,px+1,py,1,1)
spr(head,px-3,py-3,1,1) spr(head,px-3,py-3,1,1)
else else
spr(16,px-6,py-2,1,1,true) spr(16,px-6,py-2,1,1,true)
if (self.rope and self.fall_frame==0) self.rope:draw() if (self.rope and invis_level<=0.25) self.rope:draw()
spr(17,px-1,py,1,1,true) spr(17,px-1,py,1,1,true)
spr(head,px+3,py-3,1,1,true) spr(head,px+3,py-3,1,1,true)
end end
@ -1338,22 +1389,22 @@ end
__gfx__ __gfx__
000000000003000000000033000300000000000000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000 000000000003000000000022000300000000000000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000
000000000333330000003333033333000aa00aa000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000 000000000333330000003322033333000aa00aa000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000
000000009933399000399330933333900aaaaaa000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000 000000009933399000399320933333900aaaaaa000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000
000000009a333a90033a9330933333900aaaaaa000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000 000000009a333a90033a9320933333900aaaaaa000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000
000000003333333033333300033333000099990000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000 000000002333332033333200022222000099990000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000
0000000003333300000033000333330000aaaa0000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000 0000000002222200000022000222220000aaaa0000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000
0000000000333c0003333c0000333000000aa00000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000 0000000000222c0002222c0000222000000aa00000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000
000000000000cc000000cc000000cc000044440000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000 000000000000cc000000cc000000cc000044440000000000000000000000000000000000000000000000000000000000dddddddd000000000000000000000000
0000ee00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000 0000ff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000
000e00e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000 000f00f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000
00e0000e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000 00d0000f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000
00e0e00e00c0c0c00000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000 00d0d00f00c040500000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000
00ee00ee00ccccc00000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000 00dd00ee00c445500000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000
00000ee00ccccccc0000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000 00000ee00c4445550000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000
00eeee000c00c00c0000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000 00eeee000c0040050000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000
eeee0000cc0cc0cc0000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000 eeee0000cc0440550000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000
00000000000a90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000a90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000aaaaaaa91000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000aaaaaaa91000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000aaaaaa1a91100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000aaaaaa1a91100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000