calculate some weights
This commit is contained in:
parent
971d2b4ed1
commit
face68b632
15
picogora.p8
15
picogora.p8
@ -74,7 +74,8 @@ function add_lever(x,y,len)
|
||||
l.x = x
|
||||
l.y = y
|
||||
l.len = len
|
||||
l.angle = 0
|
||||
l.angle = 0.06
|
||||
l.weight = 0
|
||||
add(levers, l)
|
||||
end
|
||||
|
||||
@ -109,7 +110,16 @@ function update_player()
|
||||
end
|
||||
|
||||
function update_lever(l)
|
||||
l.angle -= 0.0005
|
||||
weight = 0
|
||||
for i=0,l.len do
|
||||
x = l.x + i
|
||||
y = l.y + i * sin(l.angle) - 1
|
||||
while pget(x, y) == white do
|
||||
weight += 1
|
||||
y -= 1
|
||||
end
|
||||
end
|
||||
l.weight = weight
|
||||
end
|
||||
|
||||
function update_drop(d)
|
||||
@ -181,6 +191,7 @@ function draw_lever(l)
|
||||
dy = l.len * sin(l.angle)
|
||||
line(l.x,l.y,l.x+dx,l.y+dy,brown)
|
||||
circ(l.x,l.y,1,black)
|
||||
print(""..l.weight,1,13,red)
|
||||
end
|
||||
|
||||
__gfx__
|
||||
|
Loading…
Reference in New Issue
Block a user