explosion ripples
This commit is contained in:
parent
4ec43e7ce9
commit
079627b659
@ -147,7 +147,6 @@ function start_level(n)
|
|||||||
level = levels[n]
|
level = levels[n]
|
||||||
puzzle_grid = {}
|
puzzle_grid = {}
|
||||||
for y=1,GRID_H do
|
for y=1,GRID_H do
|
||||||
printh(y)
|
|
||||||
puzzle_grid[y] = {0, 0, 0, 0, 0, 0, 0, 0}
|
puzzle_grid[y] = {0, 0, 0, 0, 0, 0, 0, 0}
|
||||||
for x=1,GRID_W do
|
for x=1,GRID_W do
|
||||||
puzzle_grid[y][x] = mget(x+level.mapx-1, y+level.mapy-1)
|
puzzle_grid[y][x] = mget(x+level.mapx-1, y+level.mapy-1)
|
||||||
@ -158,8 +157,52 @@ function start_level(n)
|
|||||||
bomb_spr = make_sprite(bomb_x*8, bomb_y*8, "bomb_s", 0)
|
bomb_spr = make_sprite(bomb_x*8, bomb_y*8, "bomb_s", 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
particles = {}
|
||||||
|
function add_explosion(gx, gy)
|
||||||
|
local x = gx*8+4
|
||||||
|
local y = gy*8+4
|
||||||
|
for i=0,50 do
|
||||||
|
local angle = rnd()
|
||||||
|
add(particles, {
|
||||||
|
x=x, y=y,
|
||||||
|
vx=(rnd(1)+1)*cos(angle),
|
||||||
|
vy=(rnd(1)+1)*sin(angle),
|
||||||
|
age=rnd(5),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function draw_explosions()
|
||||||
|
for p in all(particles) do
|
||||||
|
pset(p.x, p.y, p.color)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function update_explosions()
|
||||||
|
for i=#particles,1,-1 do
|
||||||
|
local p = particles[i]
|
||||||
|
p.x += p.vx
|
||||||
|
p.y += p.vy
|
||||||
|
p.age += 1
|
||||||
|
if p.age > 25 then
|
||||||
|
deli(particles, i)
|
||||||
|
elseif p.age > 20 then
|
||||||
|
p.color = 10
|
||||||
|
elseif p.age > 15 then
|
||||||
|
p.color = rnd({9, 10})
|
||||||
|
elseif p.age > 10 then
|
||||||
|
p.color = 9
|
||||||
|
elseif p.age > 5 then
|
||||||
|
p.color = rnd({8, 9})
|
||||||
|
else
|
||||||
|
p.color = 8
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function draw_level()
|
function draw_level()
|
||||||
cls()
|
cls()
|
||||||
|
-- HUD
|
||||||
map(0, 8, 0, 0, 16, 16)
|
map(0, 8, 0, 0, 16, 16)
|
||||||
for y=1,GRID_H do
|
for y=1,GRID_H do
|
||||||
for x=1,GRID_W do
|
for x=1,GRID_W do
|
||||||
@ -175,6 +218,7 @@ function draw_level()
|
|||||||
bomb_spr.x = bomb_x * 8
|
bomb_spr.x = bomb_x * 8
|
||||||
bomb_spr.y = bomb_y * 8
|
bomb_spr.y = bomb_y * 8
|
||||||
draw_sprite(bomb_spr)
|
draw_sprite(bomb_spr)
|
||||||
|
draw_explosions()
|
||||||
end
|
end
|
||||||
|
|
||||||
function can_move(dx, dy)
|
function can_move(dx, dy)
|
||||||
@ -196,7 +240,7 @@ function update_level()
|
|||||||
fall_speed /= 2
|
fall_speed /= 2
|
||||||
if bomb_spr.speed == 0 and bomb_spr.anim then
|
if bomb_spr.speed == 0 and bomb_spr.anim then
|
||||||
bomb_spr.anim = nil
|
bomb_spr.anim = nil
|
||||||
puzzle_grid[bomb_y][bomb_x] = GRID_EXPLODE
|
puzzle_grid[bomb_y][bomb_x] = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if t() - last_gravity > fall_speed then
|
if t() - last_gravity > fall_speed then
|
||||||
@ -204,18 +248,22 @@ function update_level()
|
|||||||
for y=1,GRID_H 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_NEXT then
|
||||||
|
add_explosion(x, y)
|
||||||
|
puzzle_grid[y][x] = GRID_EXPLODE
|
||||||
|
end
|
||||||
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] == BOX_FIRE 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_NEXT
|
||||||
end
|
end
|
||||||
if y < GRID_H and puzzle_grid[y+1][x] == BOX_FIRE 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_NEXT
|
||||||
end
|
end
|
||||||
if x > 1 and puzzle_grid[y][x-1] == BOX_FIRE 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_NEXT
|
||||||
end
|
end
|
||||||
if x < GRID_W and puzzle_grid[y][x+1] == BOX_FIRE 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_NEXT
|
||||||
end
|
end
|
||||||
puzzle_grid[y][x] = 0
|
puzzle_grid[y][x] = 0
|
||||||
end
|
end
|
||||||
@ -238,6 +286,11 @@ function update_level()
|
|||||||
|
|
||||||
if exploding then
|
if exploding then
|
||||||
update_sprite(bomb_spr)
|
update_sprite(bomb_spr)
|
||||||
|
if bomb_spr.frame > 10 and bomb_spr.anim then
|
||||||
|
add_explosion(bomb_x, bomb_y)
|
||||||
|
puzzle_grid[bomb_y][bomb_x] = GRID_EXPLODE
|
||||||
|
end
|
||||||
|
update_explosions()
|
||||||
-- exploding means we're done
|
-- exploding means we're done
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -270,7 +323,7 @@ end
|
|||||||
|
|
||||||
function explode()
|
function explode()
|
||||||
exploding = true
|
exploding = true
|
||||||
explode_time = t()
|
explosion_time = t()
|
||||||
bomb_spr.speed = 0.1
|
bomb_spr.speed = 0.1
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -291,7 +344,8 @@ BOX_FIRE = 139
|
|||||||
BOX_FROG = 140
|
BOX_FROG = 140
|
||||||
BOX_NUKE = 141
|
BOX_NUKE = 141
|
||||||
BOX_WATER = 142
|
BOX_WATER = 142
|
||||||
GRID_EXPLODE = 76
|
GRID_EXPLODE = -1
|
||||||
|
GRID_EXPLODE_NEXT = -2
|
||||||
|
|
||||||
animations = {
|
animations = {
|
||||||
boy_walk={frames={[0]=2, 0, 4, 0}, w=2, h=2},
|
boy_walk={frames={[0]=2, 0, 4, 0}, w=2, h=2},
|
||||||
|
Loading…
Reference in New Issue
Block a user