From ca7517cc3ae95a03420f2e82425d741c21d340c2 Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sun, 4 Feb 2024 21:52:50 -0800 Subject: [PATCH] splash! --- vacation.p8 | 54 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/vacation.p8 b/vacation.p8 index ce5fccf..8058364 100644 --- a/vacation.p8 +++ b/vacation.p8 @@ -410,7 +410,7 @@ phinstate_rise_wax = phinstate_dive_wane phinstate_rise_full = phinstate_dive_full phinstate_error = { - s={17}, + s={0}, ws=1, hs=2, } @@ -568,7 +568,7 @@ end -- 10: word primary (yellow 10?) -- 11: word shadow (wood 132?) -- 12: dolphin eye --- 13: light splashy water (12), maybe sky? +-- 13: common sky color -- 14: dolphin primary color -- 15: highlight white (all layers) -- @@ -619,7 +619,7 @@ mknew(sea) function sea:draw() local w = wave() - rectfill(0, 72+w, 128, 80+w, 0) + rectfill(0, 64+w, 128, 80+w, 0) poke2(0x5f78, 0xFF00.00FF <<> w) rectfill(0, 81+w, 128, 89+w, 0x1040.a842) rectfill(0, 90+w, 128, 97+(w>>1), 0x1004.e169) @@ -639,8 +639,8 @@ mknew(arcade_level, function(x) -- TODO: decent looking sky and sea x.sky = bg.new{c=13} x.sea = sea.new() - -- event list includes words - x.e = event_list.new() + x.bg = event_list.new() + x.fg = event_list.new() -- TODO: score renderer x.t0 = t() @@ -648,8 +648,9 @@ mknew(arcade_level, function(x) x.sky, x.sea, x.waves, + x.bg, x.phin, - x.e, + x.fg, } x.s = scootbox.new() @@ -670,22 +671,63 @@ function arcade_level:draw() self.s:draw() end +function arcade_level:draw_splash(x, force) + if (force < 1) return + local n = (force + rnd(force)) & 0x7FF + for i=0,n do + local d = droplet.new{x=x, force=force, y=72+wave(), f=i/n-0.5} + if d.dr < 0 then + self.bg:push_back(d) + else + self.fg:push_back(d) + end + end +end + function arcade_level:dive_splash(x) -- TODO: sfx, vfx for dive input + self:draw_splash(x, 3.8) end function arcade_level:jump_splash(x) -- TODO: sfx, vfx for jump input + self:draw_splash(x, 3.8) end function arcade_level:surfacing_splash(x, force, harder) -- TODO: sfx, vfx for surfacing from a dive + self:draw_splash(x, force) end function arcade_level:landing_splash(x, force, harder) -- TODO: sfx, vfx for landing from a jump + self:draw_splash(x, force) end +droplet = {} +mknew(droplet, function(d) + d.dx = d.f * d.force >> 2 + d.x += 16 * d.f + d.dy = -rnd(d.force>>1) + d.r = rnd(1) + 1 + d.dr = rnd(0.025) - 0.0125 + d.ymo = 255 * d.dr + d.c = rnd(splashcols) +end) + +function droplet:update() + self.x += self.dx + self.y += self.dy + self.r += self.dr + self.dy += 0.3 + return self.y > self.ymo + 72 + wave() or self.r < 0.5 +end + +function droplet:draw() + circfill(self.x, self.y, self.r, 0x1003) + local r2 = self.r >> 1 + pset(self.x+r2, self.y-r2, 0x100F) +end -->8 -- game sequencer