From a4cc495c487de057f662a57a11513780f39f4336 Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Wed, 7 Feb 2024 23:11:14 -0800 Subject: [PATCH] use fade-out from my shmup engine --- vacation.p8 | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/vacation.p8 b/vacation.p8 index 4946133..066b822 100644 --- a/vacation.p8 +++ b/vacation.p8 @@ -372,6 +372,28 @@ end -->8 -- 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 -- awakener @@ -491,7 +513,7 @@ function toyphin:update() x += 1 self.entered = x >= 16 elseif self.exiting then - if x > 128 then + if x + self.state.xo > 128 then self.exited = true else x += 1 @@ -701,7 +723,7 @@ mknew(sea) function sea:draw() local w = wave() - rectfill(0, 66+w, 128, 77+w, 0) + rectfill(0, 66+w, 128, 77+w, 0x1000) poke2(0x5f78, 0xffe0.00ff <<> w) rectfill(0, 78+w, 128, 89+w, 0x1040.a842) rectfill(0, 90+w, 128, 97+(w>>1), 0x1004.e169) @@ -748,9 +770,10 @@ mknew(arcade_level, function(x) x.fg, x.words, } - - x.s = scootbox.new() - x.s:push(x.v) + x.d = ditherer.new{ + c=1, + di = 0.34, + } -- TODO: fade in level music @@ -772,12 +795,13 @@ function arcade_level:update() if self.wordremain <= 0 and self.words.next == nil then self.phin.exiting = true 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, -- level state tracking and -- progression, etc. - self.s:update() - if (self.s:done()) seq:next() end function arcade_level:spawn_word() @@ -801,7 +825,8 @@ end function arcade_level:draw() setup_arcade_pal() - self.s:draw() + self.v:draw() + self.d:draw() end function arcade_level:draw_splash(x, force)