diff --git a/games/boybomb.p8 b/games/boybomb.p8 index bd4473e..b8c514c 100644 --- a/games/boybomb.p8 +++ b/games/boybomb.p8 @@ -8,7 +8,8 @@ __lua__ function _init() palt(11, true) palt(0, false) - start_scene("explainer") + start_level(1) + last_gravity = t() end function _update() @@ -35,10 +36,6 @@ function scene_time() return time() - _scene_start end -_scene = nil -_scenes = {} -_scene_start = 0 - function draw_title() cls() print("title " .. scene_time()) @@ -50,7 +47,6 @@ function update_title() end end -_scenes.title = {start=nil, draw=draw_title, update=update_title} function draw_dusk() cls() @@ -140,7 +136,98 @@ function start_explainer() exp_phase = "boy" end +function start_level(n) + start_scene("level") + puzzle_grid = { + {137, 0, 0, 0, 0, 0, 0, 137}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {137, 137, 137, 137, 137, 137, 137, 137}, + {137, 137, 137, 137, 137, 137, 137, 137}, + {137, 137, 137, 137, 137, 137, 137, 137}, + {137, 137, 137, 137, 137, 137, 137, 137}, + } + bomb_x = 4 + bomb_y = 4 +end + +function draw_level() + local xoff = 0 + local yoff = 0 + cls() + map(0, 8, 0, 0, 16, 16) + for y=1,GRID_H do + for x=1,GRID_W do + n = puzzle_grid[y][x] + if n > 0 then + spr(n, xoff+x*8, yoff+y*8) + end + end + end + + print(" lobby", 90, 6) + + spr(64, xoff+bomb_x*8, yoff+bomb_y*8) +end + +function can_move(dx, dy) + local ny = bomb_y+dy + local nx = bomb_x+dx + if ny == 0 or ny > 8 or nx == 0 or nx > 8 then + return false + end + if puzzle_grid[ny][nx] ~= 0 then + return false + end + printh(ny, nx) + return true +end + +function update_level() + if btnp(⬅️) and can_move(-1, 0) then + bomb_x -= 1 + end + if btnp(➡️) and can_move(1, 0) then + bomb_x += 1 + end + if btnp(⬇️) and can_move(0, 1) then + bomb_y += 1 + end + if btnp(⬆️) and can_move(0, -1) then + bomb_y -= 1 + end + + -- gravity + if t() - last_gravity > 0.5 then + last_gravity = t() + for y=GRID_H-1,1,-1 do + for x=1,GRID_W do + if puzzle_grid[y+1][x] == 0 then + puzzle_grid[y+1][x] = puzzle_grid[y][x] + puzzle_grid[y][x] = 0 + end + end + end + if bomb_y < GRID_H and puzzle_grid[bomb_y+1][bomb_x] == 0 then + bomb_y += 1 + end + end +end + +-- globals +_scene = nil +_scenes = {} +_scene_start = 0 + +_scenes.title = {start=nil, draw=draw_title, update=update_title} _scenes.explainer = {start=start_explainer, draw=draw_explainer, update=update_explainer} +_scenes.level = {start=nil, draw=draw_level, update=update_level} + +GRID_W = 8 +GRID_H = 9 +GRID_CRATE = 137 animations = { boy_walk={frames={[0]=2, 0, 4, 0}, w=2, h=2}, @@ -250,30 +337,30 @@ bb6666666666666666666666666666bbbb66c6c6c646c6c66c6c6c646c6c66bb0000000000000000 33333333335335333333333300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 33333333353353333333333300000000000000000000000000000000000000006666666600000000000000000000000000000000000000000000000000000000 33333333353353333333333300000000000000000000000000000000000000003333333300000000000000000000000000000000000000000000000000000000 -00555555555555555555550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -05666666666666666666665000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56666666666666666666666500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56666666555555556666666500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56666555000000005556666500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56665500000000000055666500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56665000000000000005666500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56665000000000000005666500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56650000000000000000566500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56650000000000000000566500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56650000000000000000566500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56650000000000000000566500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56650000000000000000566500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56650000000000000000566500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56650000000000000000566500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56650000000000000000566500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56665000000000000005666500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56665000000000000005666500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56665500000000000055666500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56666555000000005556666500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56666666555555556666666500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -56666666666666666666666500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -05666666666666666666665000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00555555555555555555550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00555555555555555555550000555555555555555555550000000000000000000000000000000000000000000000000000000000000000000000000000000000 +05666666666666666666665005666666666666666666665000000000000000000000000000000000000000000000000000000000000000000000000000000000 +56666666666666666666666556666666666666666666666500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56666666555555556666666556666666555555556666666500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56666555776677665556666556666555000000005556666500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56665566776677667755666556665500000000000055666500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56665677667766776675666556665000000000000005666500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56665677667766776675666556665000000000000005666500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56657766776677667766566556650000000000000000566500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56657766776677667766566556650000000000000000566500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56656677667766776677566556650000000000000000566500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56656677667766776677566556650000000000000000566500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56657766776677667766566556650000000000000000566500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56657766776677667766566556650000000000000000566500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56656677667766776677566556650000000000000000566500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56656677667766776677566556650000000000000000566500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56665766776677667765666556665000000000000005666500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56665766776677667765666556665000000000000005666500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56665577667766776655666556665500000000000055666500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56666555667766775556666556666555000000005556666500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56666666555555556666666556666666555555556666666500000000000000000000000000000000000000000000000000000000000000000000000000000000 +56666666666666666666666556666666666666666666666500000000000000000000000000000000000000000000000000000000000000000000000000000000 +05666666666666666666665005666666666666666666665000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00555555555555555555550000555555555555555555550000000000000000000000000000000000000000000000000000000000000000000000000000000000 __map__ 0000000000000000000000008081828380818200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000070000009091929390919200000084858687000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @@ -283,17 +370,17 @@ __map__ b2b2b2b2b2b2b2b2b2b8b8b8b8b8b8b80000000000b8b8b8b8b8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b2b2b2b2b2b2b2b2b2b0b0b0b0b0b0b00000000000b0b0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -c0c1c1c1c1c1c1c1c1c2c0c1c1c1c1c200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -d08989898989898989d2e0e1e1e1e1e200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -d08989898989898989d2c0c1c1c1c1c200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -d08989898989898989d2d000000000d200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -d08989890000898989d2d000000800d200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -d08989890000898989d2d000001800d20000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -d08989890000898989d2d000000000d20000000000001a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -d08989898989898989d2d000000000d200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -d08989898989898989d2d000000000d200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -d08989898989898989d2d000000000d200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -e0e1e1e1e1e1e1e1e1e2e0e1e1e1e1e200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -c0c1c1c1c1c1c1c1c1c1c1c1c1c1c1c200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -d0d1d1d1d1d1d1d1d1d1d1d1d1d100d200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -e0e1e1e1e1e1e1e1e1e1e1e1e1e1e1e200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +c0c1c1c1c1c1c1c1c1c2c3c4c4c4c4c500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +d0d1d1d1d1d1d1d1d1d2e3e4e4e4e4e500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +d0d1d1d1d1d1d1d1d1d2c3c4c4c4c4c500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +d0d1d1d1d1d1d1d1d1d2d300000000d500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +d0d1d1d1d1d1d1d1d1d2d300000800d500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +d0d1d1d1d1d1d1d1d1d2d300001800d50000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +d0d1d1d1d1d1d1d1d1d2d300000000d50000000000001a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +d0d1d1d1d1d1d1d1d1d2d300000000d500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +d0d1d1d1d1d1d1d1d1d2d300000000d500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +d0d1d1d1d1d1d1d1d1d2d300000000d500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +e0e1e1e1e1e1e1e1e1e2e3e4e4e4e4e500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +c3c4c4c4c4c4c4c4c4c4c4c4c4c4c4c500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +d3d4d4d4d4d4d4d4d4d4d4d4d4d400d500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +e3e4e4e4e4e4e4e4e4e4e4e4e4e4e4e500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000