drops can fall left or right
This commit is contained in:
parent
b503e41add
commit
cc338a6dc4
65
picogora.p8
65
picogora.p8
@ -26,7 +26,15 @@ end
|
|||||||
-->8
|
-->8
|
||||||
-- game code
|
-- game code
|
||||||
|
|
||||||
bg = 12
|
bg = blue
|
||||||
|
|
||||||
|
function _init()
|
||||||
|
-- button-press initial delay
|
||||||
|
poke(0x5f5c, 2)
|
||||||
|
-- button-press repeat
|
||||||
|
poke(0x5f5d, 2)
|
||||||
|
init_world()
|
||||||
|
end
|
||||||
|
|
||||||
function init_world()
|
function init_world()
|
||||||
player = {}
|
player = {}
|
||||||
@ -38,20 +46,8 @@ function init_world()
|
|||||||
ramps = {}
|
ramps = {}
|
||||||
add_ramp(50,20,15,10)
|
add_ramp(50,20,15,10)
|
||||||
add_ramp(60,50,15,-15)
|
add_ramp(60,50,15,-15)
|
||||||
add_ramp(50,60,20,0)
|
add_ramp(48,60,20,0)
|
||||||
end
|
add_ramp(45,75,10,30)
|
||||||
|
|
||||||
function _init()
|
|
||||||
-- button-press initial delay
|
|
||||||
poke(0x5f5c, 1)
|
|
||||||
-- button-press repeat
|
|
||||||
poke(0x5f5d, 2)
|
|
||||||
init_world()
|
|
||||||
end
|
|
||||||
|
|
||||||
function _update()
|
|
||||||
update_player()
|
|
||||||
update_drops()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function add_ramp(x,y,dx,dy)
|
function add_ramp(x,y,dx,dy)
|
||||||
@ -63,6 +59,11 @@ function add_ramp(x,y,dx,dy)
|
|||||||
add(ramps, r)
|
add(ramps, r)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function _update()
|
||||||
|
update_player()
|
||||||
|
update_drops()
|
||||||
|
end
|
||||||
|
|
||||||
function update_player()
|
function update_player()
|
||||||
if btn(0) then
|
if btn(0) then
|
||||||
player.x -= 1
|
player.x -= 1
|
||||||
@ -89,14 +90,39 @@ function update_player()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function update_drop(d)
|
||||||
|
if d.y == 127 or pget(d.x,d.y+1) == bg then
|
||||||
|
d.y += 1
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
left = pget(d.x-1,d.y) == bg and pget(d.x-1,d.y+1) == bg
|
||||||
|
right = pget(d.x+1,d.y) == bg and pget(d.x+1,d.y+1) == bg
|
||||||
|
|
||||||
|
if left and right then
|
||||||
|
d.y += 1
|
||||||
|
if rnd() < 0.5 then
|
||||||
|
d.x -= 1
|
||||||
|
else
|
||||||
|
d.x += 1
|
||||||
|
end
|
||||||
|
elseif left then
|
||||||
|
d.y += 1
|
||||||
|
d.x -= 1
|
||||||
|
elseif right then
|
||||||
|
d.y += 1
|
||||||
|
d.x += 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function update_drops()
|
function update_drops()
|
||||||
draw_world()
|
draw_world()
|
||||||
new_drops = {}
|
new_drops = {}
|
||||||
for i=1,#drops do
|
for i=1,#drops do
|
||||||
drop = drops[i]
|
d = drops[i]
|
||||||
drop.y += 1
|
update_drop(d)
|
||||||
if drop.y < 128 then
|
if d.y < 128 then
|
||||||
add(new_drops, drop)
|
add(new_drops, d)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
drops = new_drops
|
drops = new_drops
|
||||||
@ -122,7 +148,6 @@ function draw_drop(drop)
|
|||||||
pset(drop.x, drop.y, white)
|
pset(drop.x, drop.y, white)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
__gfx__
|
__gfx__
|
||||||
000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
00000000aaa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
00000000aaa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
Loading…
Reference in New Issue
Block a user