|
@ -3,6 +3,8 @@ version 32 |
|
|
__lua__ |
|
|
__lua__ |
|
|
-- game code |
|
|
-- game code |
|
|
|
|
|
|
|
|
|
|
|
bg = 12 |
|
|
|
|
|
|
|
|
function init_world() |
|
|
function init_world() |
|
|
player = {} |
|
|
player = {} |
|
|
player.x = 64 |
|
|
player.x = 64 |
|
@ -10,6 +12,10 @@ function init_world() |
|
|
player.spr = 1 |
|
|
player.spr = 1 |
|
|
|
|
|
|
|
|
drops = {} |
|
|
drops = {} |
|
|
|
|
|
ramps = {} |
|
|
|
|
|
add_ramp(50,20,15,10) |
|
|
|
|
|
add_ramp(60,50,15,-15) |
|
|
|
|
|
add_ramp(50,60,20,0) |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
function _init() |
|
|
function _init() |
|
@ -25,6 +31,15 @@ function _update() |
|
|
update_drops() |
|
|
update_drops() |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function add_ramp(x,y,dx,dy) |
|
|
|
|
|
r = {} |
|
|
|
|
|
r.x = x |
|
|
|
|
|
r.y = y |
|
|
|
|
|
r.dx = dx |
|
|
|
|
|
r.dy = dy |
|
|
|
|
|
add(ramps, r) |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
function update_player() |
|
|
function update_player() |
|
|
if btn(0) then |
|
|
if btn(0) then |
|
|
player.x -= 1 |
|
|
player.x -= 1 |
|
@ -52,6 +67,7 @@ function update_player() |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
function update_drops() |
|
|
function update_drops() |
|
|
|
|
|
draw_world() |
|
|
new_drops = {} |
|
|
new_drops = {} |
|
|
for i=1,#drops do |
|
|
for i=1,#drops do |
|
|
drop = drops[i] |
|
|
drop = drops[i] |
|
@ -64,12 +80,21 @@ function update_drops() |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
function _draw() |
|
|
function _draw() |
|
|
cls(blue) |
|
|
|
|
|
foreach(drops, draw_drop) |
|
|
|
|
|
|
|
|
draw_world() |
|
|
spr(player.spr,player.x-1,player.y-1) |
|
|
spr(player.spr,player.x-1,player.y-1) |
|
|
print("drops: "..#drops, 1, 6, white) |
|
|
print("drops: "..#drops, 1, 6, white) |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function draw_world() |
|
|
|
|
|
cls(bg) |
|
|
|
|
|
foreach(drops, draw_drop) |
|
|
|
|
|
foreach(ramps, draw_ramp) |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function draw_ramp(r) |
|
|
|
|
|
line(r.x,r.y,r.x+r.dx,r.y+r.dy,brown) |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
function draw_drop(drop) |
|
|
function draw_drop(drop) |
|
|
pset(drop.x, drop.y, white) |
|
|
pset(drop.x, drop.y, white) |
|
|
end |
|
|
end |
|
|