diff --git a/games/boybomb.p8 b/games/boybomb.p8 index 7c99762..df053c7 100644 --- a/games/boybomb.p8 +++ b/games/boybomb.p8 @@ -11,7 +11,7 @@ function _init() palt(0, false) -- start first scene --start_level(1) - start_scene("title") + start_scene("explainer") end function _update() @@ -258,7 +258,45 @@ function can_move(dx, dy) return true end +function explosion_adjacent(x, y) + -- called when the block next door explodes + local block = puzzle_grid[y][x] + if block == BOX_WOOD then + puzzle_grid[y][x] = 0 + elseif block == BOX_FIRE then + puzzle_grid[y][x] = GRID_EXPLODE_NEXT + end +end + +function process_block(x, y) + local block = puzzle_grid[y][x] + if block == GRID_EXPLODE_NEXT then + add_explosion(x, y) + puzzle_grid[y][x] = GRID_EXPLODE + elseif block == GRID_EXPLODE then + if y > 1 then + explosion_adjacent(x, y-1) + end + if y < GRID_H then + explosion_adjacent(x, y+1) + end + if x > 1 then + explosion_adjacent(x-1, y) + end + if x < GRID_W then + explosion_adjacent(x+1, y) + end + puzzle_grid[y][x] = 0 + end +end + + function update_level() + -- bombs break adjacent tiles + -- fire boxes turn into more bombs + -- goal: break all boxes + -- ??? only 8 positions? + -- update grid fall_speed = 0.3 if exploding then @@ -272,26 +310,7 @@ function update_level() last_gravity = t() for y=1,GRID_H do for x=1,GRID_W do - -- explode - if puzzle_grid[y][x] == GRID_EXPLODE_NEXT then - add_explosion(x, y) - puzzle_grid[y][x] = GRID_EXPLODE - end - if puzzle_grid[y][x] == GRID_EXPLODE then - if y > 1 and puzzle_grid[y-1][x] == BOX_FIRE then - puzzle_grid[y-1][x] = GRID_EXPLODE_NEXT - end - if y < GRID_H and puzzle_grid[y+1][x] == BOX_FIRE then - puzzle_grid[y+1][x] = GRID_EXPLODE_NEXT - end - if x > 1 and puzzle_grid[y][x-1] == BOX_FIRE then - puzzle_grid[y][x-1] = GRID_EXPLODE_NEXT - end - if x < GRID_W and puzzle_grid[y][x+1] == BOX_FIRE then - puzzle_grid[y][x+1] = GRID_EXPLODE_NEXT - end - puzzle_grid[y][x] = 0 - end + process_block(x, y) -- fall down if y < GRID_H and puzzle_grid[y+1][x] == 0