From 9348186d6db265be6b6ebfe6b3e83b79d36e20df Mon Sep 17 00:00:00 2001 From: James Turk Date: Tue, 25 Apr 2023 23:06:50 -0500 Subject: [PATCH] explode materials --- games/boybomb.p8 | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/games/boybomb.p8 b/games/boybomb.p8 index d366dd9..c97b844 100644 --- a/games/boybomb.p8 +++ b/games/boybomb.p8 @@ -183,7 +183,7 @@ function start_level(n) end particles = {} -function add_explosion(gx, gy) +function add_explosion(gx, gy, colors) sfx(0) local x = gx*8+4 local y = gy*8+4 @@ -193,7 +193,8 @@ function add_explosion(gx, gy) x=x, y=y, vx=(rnd(1)+1)*cos(angle), vy=(rnd(1)+1)*sin(angle), - age=30+rnd(10), + age=10+rnd(10), + color=rnd(colors), }) end end @@ -212,16 +213,6 @@ function update_explosions() p.age -= 1 if p.age <= 0 then deli(particles, i) - elseif p.age > 40 then - p.color = 8 - elseif p.age > 30 then - p.color = rnd({8, 9}) - elseif p.age > 20 then - p.color = 9 - elseif p.age > 10 then - p.color = rnd({9, 10}) - elseif p.age > 5 then - p.color = 10 end end end @@ -273,7 +264,7 @@ function process_block(x, y) -- called on each block each frame local block = puzzle_grid[y][x] if block == GRID_EXPLODE_NEXT then - add_explosion(x, y) + add_explosion(x, y, {4, 15}) -- wood puzzle_grid[y][x] = GRID_EXPLODE elseif block == GRID_EXPLODE then if y > 1 then @@ -310,7 +301,7 @@ function update_level() end if t() - last_gravity > fall_speed then last_gravity = t() - for y=1,GRID_H do + for y=GRID_H,1,-1 do for x=1,GRID_W do process_block(x, y) -- fall down @@ -337,7 +328,7 @@ function update_level() if exploding then if bomb_spr.frame > 10 and bomb_spr.anim then -- when explosion hits last frame, particles / update grid - add_explosion(bomb_x, bomb_y) + add_explosion(bomb_x, bomb_y, {8, 9, 10}) puzzle_grid[bomb_y][bomb_x] = GRID_EXPLODE end -- exploding means we're done before input comes