use fade-out from my shmup engine

This commit is contained in:
Kistaro Windrider 2024-02-07 23:11:14 -08:00
parent 523361500a
commit a4cc495c48
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -372,6 +372,28 @@ end
-->8 -->8
-- zonk renderer -- zonk renderer
fadetable = split"0,1.5,1025.5,1029.5,1285.5,1413.5,9605.5,9637.5,-23130.5,-23066.5,-18970.5,-18954.5,-2570.5,-2568.5,-520.5,-8.5,-0.5"
ditherer = {
i = 0,
di = 0.25,
c=0,
pattern=fadetable,
}
mknew(ditherer)
function ditherer:update()
self.i += self.di
return self.i < 0 or self.i >= #self.pattern + 1
end
function ditherer:draw()
local idx = min(flr(self.i), #self.pattern)
if (idx < 1) idx = 1
fillp(self.pattern[#self.pattern+1-idx])
rectfill(0,0,128,128,self.c)
end
-->8 -->8
-- awakener -- awakener
@ -491,7 +513,7 @@ function toyphin:update()
x += 1 x += 1
self.entered = x >= 16 self.entered = x >= 16
elseif self.exiting then elseif self.exiting then
if x > 128 then if x + self.state.xo > 128 then
self.exited = true self.exited = true
else else
x += 1 x += 1
@ -701,7 +723,7 @@ mknew(sea)
function sea:draw() function sea:draw()
local w = wave() local w = wave()
rectfill(0, 66+w, 128, 77+w, 0) rectfill(0, 66+w, 128, 77+w, 0x1000)
poke2(0x5f78, 0xffe0.00ff <<> w) poke2(0x5f78, 0xffe0.00ff <<> w)
rectfill(0, 78+w, 128, 89+w, 0x1040.a842) rectfill(0, 78+w, 128, 89+w, 0x1040.a842)
rectfill(0, 90+w, 128, 97+(w>>1), 0x1004.e169) rectfill(0, 90+w, 128, 97+(w>>1), 0x1004.e169)
@ -748,9 +770,10 @@ mknew(arcade_level, function(x)
x.fg, x.fg,
x.words, x.words,
} }
x.d = ditherer.new{
x.s = scootbox.new() c=1,
x.s:push(x.v) di = 0.34,
}
-- TODO: fade in level music -- TODO: fade in level music
@ -772,12 +795,13 @@ function arcade_level:update()
if self.wordremain <= 0 and self.words.next == nil then if self.wordremain <= 0 and self.words.next == nil then
self.phin.exiting = true self.phin.exiting = true
end end
self.s.go = self.phin.x > 90 if self.phin.x > 90 then
if (self.d:update()) seq:next()
end
self.v:update()
-- TODO: timers, word loop, -- TODO: timers, word loop,
-- level state tracking and -- level state tracking and
-- progression, etc. -- progression, etc.
self.s:update()
if (self.s:done()) seq:next()
end end
function arcade_level:spawn_word() function arcade_level:spawn_word()
@ -801,7 +825,8 @@ end
function arcade_level:draw() function arcade_level:draw()
setup_arcade_pal() setup_arcade_pal()
self.s:draw() self.v:draw()
self.d:draw()
end end
function arcade_level:draw_splash(x, force) function arcade_level:draw_splash(x, force)