From 34712e3d548b34bb5a3499fddb67c98b0ec8ff54 Mon Sep 17 00:00:00 2001 From: James Turk Date: Sun, 16 Apr 2023 20:33:33 -0500 Subject: [PATCH] ocean anim --- games/ocean.p8 | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/games/ocean.p8 b/games/ocean.p8 index 8c8344f..420ca5a 100644 --- a/games/ocean.p8 +++ b/games/ocean.p8 @@ -53,15 +53,22 @@ function start_ocean() end function draw_ocean() - cls(1) - local ocean_anim = {0, 0, 0, 0, 0, 1, 2, 3, 4} - -- if ocean_wind_x < 0 then - -- end - for x=0,16 do - for y=0,16 do - + cls(0) + local ocean_anim = {[0]=0, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0} + if ocean_wind_x == 0 and ocean_wind_y == 0 then + return + end + for x=0,15 do + for y=0,15 do + local anim = ocean_anim[(flr(time()*4) - ocean_wind_y*y - ocean_wind_x*x) % #ocean_anim] + local base = 0 + if ocean_wind_y != 0 then base = 5 end + if anim > 0 then + spr(base+anim, 8*x, 8*y, 1, 1, ocean_wind_x < 0, ocean_wind_y < 0) + end end end + print("wind: "..ocean_wind_x..", "..ocean_wind_y) end function update_ocean() @@ -81,7 +88,7 @@ function update_ocean() end end -_scenes.ocean = {start=nil, draw=draw_ocean, update=update_ocean} +_scenes.ocean = {start=start_ocean, draw=draw_ocean, update=update_ocean} __gfx__