Compare commits

...

2 Commits

View File

@ -38,7 +38,7 @@ end
function init_world() function init_world()
player = {} player = {}
player.x = 64 player.x = 36
player.y = 16 player.y = 16
player.spr = 1 player.spr = 1
@ -46,6 +46,8 @@ function init_world()
ramps = {} ramps = {}
levers = {} levers = {}
add_ramp(70,25,40,-5)
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(52,60,14,0) add_ramp(52,60,14,0)
@ -79,7 +81,7 @@ end
function _update() function _update()
update_player() update_player()
update_drops() update_drops()
update_levers() foreach(levers, update_lever)
end end
function update_player() function update_player()
@ -95,10 +97,8 @@ function update_player()
if btn(3) then if btn(3) then
player.y += 1 player.y += 1
end end
if (player.y < 0) player.y = 0 player.x = mid(0, player.x, 127)
if (player.y > 127) player.y = 127 player.y = mid(0, player.y, 127)
if (player.x < 0) player.x = 0
if (player.x > 127) player.x = 127
if btnp(🅾️) then if btnp(🅾️) then
drop = {} drop = {}
@ -109,11 +109,7 @@ function update_player()
end end
function update_lever(l) function update_lever(l)
l.angle += 0.001 l.angle -= 0.0005
end
function update_levers()
foreach(levers, update_lever)
end end
function update_drop(d) function update_drop(d)
@ -146,10 +142,14 @@ function update_drops()
new_drops = {} new_drops = {}
for i=1,#drops do for i=1,#drops do
d = drops[i] d = drops[i]
oldx = d.x
oldy = d.y
update_drop(d) update_drop(d)
if d.y < 128 then if d.y < 128 then
add(new_drops, d) add(new_drops, d)
end end
pset(oldx, oldy, bg)
pset(d.x, d.y, white)
end end
drops = new_drops drops = new_drops
end end
@ -180,7 +180,7 @@ function draw_lever(l)
dx = l.len * cos(l.angle) dx = l.len * cos(l.angle)
dy = l.len * sin(l.angle) dy = l.len * sin(l.angle)
line(l.x,l.y,l.x+dx,l.y+dy,brown) line(l.x,l.y,l.x+dx,l.y+dy,brown)
rectfill(l.x-1,l.y-1,l.x+1,l.y+1,black) circ(l.x,l.y,1,black)
end end
__gfx__ __gfx__