Browse Source

add levers, draw cursor coordinates

main
Colin McMillen 12 months ago
parent
commit
c92508544f
  1. 43
      picogora.p8

43
picogora.p8

@ -44,14 +44,18 @@ function init_world()
drops = {}
ramps = {}
levers = {}
add_ramp(50,20,15,10)
add_ramp(60,50,15,-15)
add_ramp(48,60,20,0)
add_ramp(52,60,14,0)
add_ramp(45,75,10,30)
add_ramp(65,76,0,10)
add_ramp(65,86,5,0)
add_ramp(64,76,0,10)
add_ramp(64,86,6,0)
add_ramp(70,76,0,10)
add_lever(30,30,20)
end
function add_ramp(x,y,dx,dy)
@ -63,9 +67,19 @@ function add_ramp(x,y,dx,dy)
add(ramps, r)
end
function add_lever(x,y,len)
l = {}
l.x = x
l.y = y
l.len = len
l.angle = 0
add(levers, l)
end
function _update()
update_player()
update_drops()
update_levers()
end
function update_player()
@ -94,6 +108,14 @@ function update_player()
end
end
function update_lever(l)
l.angle += 0.001
end
function update_levers()
foreach(levers, update_lever)
end
function update_drop(d)
if d.y == 127 or pget(d.x,d.y+1) == bg then
d.y += 1
@ -135,21 +157,30 @@ end
function _draw()
draw_world()
spr(player.spr,player.x-1,player.y-1)
print("drops: "..#drops, 1, 6, white)
print("("..player.x..","..player.y..")", 1, 1, white)
print("drops: "..#drops, 1, 7, white)
end
function draw_world()
cls(bg)
foreach(drops, draw_drop)
foreach(ramps, draw_ramp)
foreach(levers, draw_lever)
end
function draw_drop(drop)
pset(drop.x, drop.y, white)
end
function draw_ramp(r)
line(r.x,r.y,r.x+r.dx,r.y+r.dy,brown)
end
function draw_drop(drop)
pset(drop.x, drop.y, white)
function draw_lever(l)
dx = l.len * cos(l.angle)
dy = l.len * sin(l.angle)
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)
end
__gfx__

Loading…
Cancel
Save