explode grid
This commit is contained in:
parent
ce1cf303d5
commit
d33aca6f9f
113
games/boybomb.p8
113
games/boybomb.p8
@ -161,24 +161,25 @@ end
|
|||||||
|
|
||||||
levels = {
|
levels = {
|
||||||
{name="lobby 1",
|
{name="lobby 1",
|
||||||
mapx=16, mapy=8,
|
mapx=16, mapy=8, par=1, boss=8,
|
||||||
par=2, boss=8,
|
|
||||||
message="there's no way he'll\nclear these boxes"
|
message="there's no way he'll\nclear these boxes"
|
||||||
},
|
},
|
||||||
{name="lobby 2",
|
{name="lobby 2",
|
||||||
mapx=25, mapy=8,
|
mapx=25, mapy=8, par=2, boss=8,
|
||||||
par=2, boss=8,
|
|
||||||
message="this one should take a\ndozen explosions"
|
message="this one should take a\ndozen explosions"
|
||||||
},
|
},
|
||||||
{name="lobby 3",
|
{name="lobby 3",
|
||||||
mapx=31, mapy=8, bomb_x=6, bomb_y=7,
|
mapx=31, mapy=8, par=8, boss=8,
|
||||||
par=2, boss=8,
|
|
||||||
message="maybe he'll wear himself\nout?"
|
message="maybe he'll wear himself\nout?"
|
||||||
},
|
},
|
||||||
{name="lab 1",
|
{name="lobby 4",
|
||||||
mapx=26, mapy=8, bomb_x=6, bomb_y=7,
|
mapx=39, mapy=8, par=2, boss=8,
|
||||||
par=5, boss=10,
|
message="being hit by a block\nwill make him explode"
|
||||||
},
|
},
|
||||||
|
{name=" lab 1",
|
||||||
|
mapx=48, mapy=8, par=2, boss=8,
|
||||||
|
message="we need to be careful\nof chain reactions",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function start_level(n)
|
function start_level(n)
|
||||||
start_scene("level")
|
start_scene("level")
|
||||||
@ -192,7 +193,9 @@ function start_level(n)
|
|||||||
bomb_y = 4
|
bomb_y = 4
|
||||||
-- load puzzle
|
-- load puzzle
|
||||||
puzzle_grid = {}
|
puzzle_grid = {}
|
||||||
|
explode_grid = {}
|
||||||
for y=1,GRID_H do
|
for y=1,GRID_H do
|
||||||
|
explode_grid[y] = {nil, nil, nil, nil, nil, nil, nil, nil}
|
||||||
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)
|
||||||
@ -211,7 +214,7 @@ function start_level(n)
|
|||||||
end
|
end
|
||||||
|
|
||||||
particles = {}
|
particles = {}
|
||||||
function add_explosion(gx, gy, colors)
|
function add_particles(gx, gy, colors)
|
||||||
sfx(0)
|
sfx(0)
|
||||||
local x = gx*8+4
|
local x = gx*8+4
|
||||||
local y = gy*8+4
|
local y = gy*8+4
|
||||||
@ -287,44 +290,53 @@ end
|
|||||||
function explosion_adjacent(x, y)
|
function explosion_adjacent(x, y)
|
||||||
-- called when the block next door explodes
|
-- called when the block next door explodes
|
||||||
local block = puzzle_grid[y][x]
|
local block = puzzle_grid[y][x]
|
||||||
if block == BOX_WOOD then
|
|
||||||
puzzle_grid[y][x] = 0
|
puzzle_grid[y][x] = 0
|
||||||
elseif block == BOX_FIRE then
|
if block == BOX_FIRE then
|
||||||
puzzle_grid[y][x] = GRID_EXPLODE_NEXT
|
-- TODO: add explosion
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function process_block(x, y)
|
function process_block(x, y)
|
||||||
-- called on each block each frame
|
-- called on each block each frame
|
||||||
local block = puzzle_grid[y][x]
|
local block = puzzle_grid[y][x]
|
||||||
if block == GRID_EXPLODE_NEXT then
|
local explode = explode_grid[y][x]
|
||||||
add_explosion(x, y, {4, 15}) -- wood
|
if explode then
|
||||||
puzzle_grid[y][x] = GRID_EXPLODE
|
-- grid items are {countdown, colors}
|
||||||
elseif block == GRID_EXPLODE then
|
explode.countdown -= 1
|
||||||
local ys = {0}
|
printh("CD: "..x..", "..y.." "..explode.countdown)
|
||||||
local xs = {0}
|
if explode.countdown == 0 then
|
||||||
if y > 1 then
|
-- blow up the box (if present)
|
||||||
add(ys, -1)
|
|
||||||
end
|
|
||||||
if y < GRID_H then
|
|
||||||
add(ys, 1)
|
|
||||||
end
|
|
||||||
if x > 1 then
|
|
||||||
add(xs, -1)
|
|
||||||
end
|
|
||||||
if x < GRID_W then
|
|
||||||
add(xs, 1)
|
|
||||||
end
|
|
||||||
for xx in all(xs) do
|
|
||||||
for yy in all(ys) do
|
|
||||||
if xx~=0 or yy~=0 then
|
|
||||||
explosion_adjacent(x+xx, y+yy)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
puzzle_grid[y][x] = 0
|
puzzle_grid[y][x] = 0
|
||||||
|
add_particles(x, y, explode.colors)
|
||||||
|
-- 4, 15 for box
|
||||||
|
explode_grid[y][x] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- elseif block == GRID_EXPLODE then
|
||||||
|
-- local ys = {0}
|
||||||
|
-- local xs = {0}
|
||||||
|
-- if y > 1 then
|
||||||
|
-- add(ys, -1)
|
||||||
|
-- end
|
||||||
|
-- if y < GRID_H then
|
||||||
|
-- add(ys, 1)
|
||||||
|
-- end
|
||||||
|
-- if x > 1 then
|
||||||
|
-- add(xs, -1)
|
||||||
|
-- end
|
||||||
|
-- if x < GRID_W then
|
||||||
|
-- add(xs, 1)
|
||||||
|
-- end
|
||||||
|
-- for xx in all(xs) do
|
||||||
|
-- for yy in all(ys) do
|
||||||
|
-- if xx~=0 or yy~=0 then
|
||||||
|
-- explosion_adjacent(x+xx, y+yy)
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- puzzle_grid[y][x] = 0
|
||||||
|
-- end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function update_level()
|
function update_level()
|
||||||
@ -342,6 +354,7 @@ function update_level()
|
|||||||
bomb_y = 0
|
bomb_y = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
printh("===")
|
||||||
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=GRID_H,1,-1 do
|
||||||
@ -371,8 +384,8 @@ function update_level()
|
|||||||
if exploding then
|
if exploding then
|
||||||
if bomb_spr.frame > 10 and bomb_spr.anim then
|
if bomb_spr.frame > 10 and bomb_spr.anim then
|
||||||
-- when explosion hits last frame, particles / update grid
|
-- when explosion hits last frame, particles / update grid
|
||||||
add_explosion(bomb_x, bomb_y, {8, 9, 10})
|
--add_particles(bomb_x, bomb_y, {8, 9, 10})
|
||||||
puzzle_grid[bomb_y][bomb_x] = GRID_EXPLODE
|
explode_grid[bomb_y][bomb_x] = {countdown=1, colors={8, 9, 10}}
|
||||||
end
|
end
|
||||||
-- exploding means we're done before input comes
|
-- exploding means we're done before input comes
|
||||||
return
|
return
|
||||||
@ -442,8 +455,6 @@ BOX_FIRE = 139
|
|||||||
BOX_FROG = 140
|
BOX_FROG = 140
|
||||||
BOX_NUKE = 141
|
BOX_NUKE = 141
|
||||||
BOX_WATER = 142
|
BOX_WATER = 142
|
||||||
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},
|
||||||
@ -717,16 +728,16 @@ b2b2b2b2b2b2b2b2b2b8b8b8b8b8b8b80000000000b8b8b8b8b80000000000000000000000000000
|
|||||||
b2b2b2b2b2b2b2b2b2b0b0b0b0b0b0b00000000000b0b0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
b2b2b2b2b2b2b2b2b2b0b0b0b0b0b0b00000000000b0b0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
c0c1c1c1c1c1c1c1c1c2c3c4c4c4c4c588888888888888880000888888888888888800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
c0c1c1c1c1c1c1c1c1c2c3c4c4c4c4c588888888888888880000888888888888888800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
d0d1d1d1d1d1d1d1d1d2e3e4e4e4e4e500000000000000000000880088888888888889008900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
d0d1d1d1d1d1d1d1d1d2e3e4e4e4e4e500000000000000000000880088888888888889008900000000890000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
d0d1d1d1d1d1d1d1d1d2c3c4c4c4c4c500000000000000000000880088888888888889988900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
d0d1d1d1d1d1d1d1d1d2c3c4c4c4c4c500000000000000000000880088888888888889988900008989890000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
d0d1d1d1d1d1d1d1d1d2d300000000d500000000000000000000888888888888888889898900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
d0d1d1d1d1d1d1d1d1d2d300000000d500000000000000000000888888888888888889898900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
d0d1d1d1d1d1d1d1d1d2d300000000d500000000000000000000880000008888888889898900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
d0d1d1d1d1d1d1d1d1d2d300000000d500000000000000000000880000008888888889898900008888880000880000008800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
d0d1d1d1d1d1d1d1d1d2d300000000d500000000000000000000880000000000888889898900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
d0d1d1d1d1d1d1d1d1d2d300000000d500000000000000000000880000000000888889898900008888888800888888008800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
d0d1d1d1d1d1d1d1d1d2d300000000d500000000000000000000880000000000888889898900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
d0d1d1d1d1d1d1d1d1d2d300000000d500000000000000000000880000000000888889898900000000000000000000008800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
d0d1d1d1d1d1d1d1d1d2d300000000d588888888888888880000880000000000888889898900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
d0d1d1d1d1d1d1d1d1d2d300000000d588888888888888880000880000000000888889898900000000000000000000008800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
d0d1d1d1d1d1d1d1d1d2d300000000d588888988898888880089889888888988888889898900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
d0d1d1d1d1d1d1d1d1d2d300000000d588888988898888880089889888888988888889898900000000000000000000008889000000890000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
d0d1d1d1d1d1d1d1d1d2d300000000d588888998898888880089888988888900888889898900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
d0d1d1d1d1d1d1d1d1d2d300000000d5888889988988888800898889888889008888898989000089000088880000890088898b008b890000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
d0d1d1d1d1d1d1d1d1d2d3d4d4d4d4d588888989898888880089898989898988888889898900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
d0d1d1d1d1d1d1d1d1d2d3d4d4d4d4d588888989898888880089898989898988888889898900008989898888898989008889898989890000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
d0d1d1d1d1d1d1d1d1d2d3d4d4d4d4d500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
d0d1d1d1d1d1d1d1d1d2d3d4d4d4d4d500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
e0e1e1e1e1e1e1e1e1e2e3e4e4e4e4e500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
e0e1e1e1e1e1e1e1e1e2e3e4e4e4e4e500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
c3c4c4c4c4c4c4c4c4c4c4c4c4c4c4c500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
c3c4c4c4c4c4c4c4c4c4c4c4c4c4c4c500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
Loading…
Reference in New Issue
Block a user