block improvements

This commit is contained in:
James Turk 2023-04-25 03:21:04 -05:00
parent 31aef6525c
commit 4ec43e7ce9

View File

@ -201,30 +201,32 @@ function update_level()
end end
if t() - last_gravity > fall_speed then if t() - last_gravity > fall_speed then
last_gravity = t() last_gravity = t()
for y=GRID_H,1,-1 do for y=1,GRID_H do
for x=1,GRID_W do for x=1,GRID_W do
-- explode -- explode
if puzzle_grid[y][x] == GRID_EXPLODE then if puzzle_grid[y][x] == GRID_EXPLODE then
if y > 1 and puzzle_grid[y-1][x] == GRID_BOX then if y > 1 and puzzle_grid[y-1][x] == BOX_FIRE then
puzzle_grid[y-1][x] = GRID_EXPLODE puzzle_grid[y-1][x] = GRID_EXPLODE
end end
if y < GRID_H and puzzle_grid[y+1][x] == GRID_BOX then if y < GRID_H and puzzle_grid[y+1][x] == BOX_FIRE then
puzzle_grid[y+1][x] = GRID_EXPLODE puzzle_grid[y+1][x] = GRID_EXPLODE
end end
if x > 1 and puzzle_grid[y][x-1] == GRID_BOX then if x > 1 and puzzle_grid[y][x-1] == BOX_FIRE then
puzzle_grid[y][x-1] = GRID_EXPLODE puzzle_grid[y][x-1] = GRID_EXPLODE
end end
if x < GRID_W and puzzle_grid[y][x+1] == GRID_BOX then if x < GRID_W and puzzle_grid[y][x+1] == BOX_FIRE then
puzzle_grid[y][x+1] = GRID_EXPLODE puzzle_grid[y][x+1] = GRID_EXPLODE
end end
--puzzle_grid[y][x] = 0 puzzle_grid[y][x] = 0
end end
-- fall down -- fall down
if y < GRID_H if y < GRID_H
and puzzle_grid[y][x] == GRID_BOX and puzzle_grid[y+1][x] == 0
and puzzle_grid[y+1][x] == 0 then and puzzle_grid[y][x] != 0
then
puzzle_grid[y+1][x] = puzzle_grid[y][x] puzzle_grid[y+1][x] = puzzle_grid[y][x]
puzzle_grid[y][x] = 0 puzzle_grid[y][x] = 0
-- crushed, explode
if y+1 == bomb_y and x == bomb_x then if y+1 == bomb_y and x == bomb_x then
explode() explode()
puzzle_grid[y+1][x] = 0 puzzle_grid[y+1][x] = 0
@ -283,7 +285,12 @@ _scenes.level = {start=nil, draw=draw_level, update=update_level}
GRID_W = 8 GRID_W = 8
GRID_H = 9 GRID_H = 9
GRID_BOX = 137 BOX_WOOD = 137
BOX_STEEL = 138
BOX_FIRE = 139
BOX_FROG = 140
BOX_NUKE = 141
BOX_WATER = 142
GRID_EXPLODE = 76 GRID_EXPLODE = 76
animations = { animations = {