Trying to reproduce the feel of tiny wings… touch to become more gravityish. Ipad 2 landscape. The ground is a little hard to see in the video, it’s a SIN curve…
function setup()
displayMode(FULLSCREEN)
--myFPSReporter = FPSReporter(4)
noSmooth()
points = {}
for i=1,2000 do
points[i] = vec2(i*20, math.sin(math.rad(i*20))*50+200)
end
slopes = physics.body(CHAIN, false, unpack(points))
player = physics.body(CIRCLE, 15)
player.restitution = .1
player.x = 100
player.y = HEIGHT - 200
player.gravityScale = .5
watch("CurrentTouch")
watch("player.gravityScale")
end
function draw()
background(0, 0, 0, 255)
--myFPSReporter:draw(3)
strokeWidth(1)
scaleY = 1
if player.y > HEIGHT-50 then
scaleY = (HEIGHT - 50) / player.y
end
pushMatrix()
scale(scaleY)
pushMatrix()
translate(200/scaleY, player.y)
rotate(player.angle)
ellipse(0, 0, player.radius*2)
line(0,0,player.radius-2,0)
popMatrix()
pushMatrix()
translate((200/scaleY)-player.x,0)
for k,v in pairs(slopes.points) do
if v.x < (WIDTH-200)/scaleY+player.x and v.x > -200/scaleY+player.x then
ellipse(v.x, v.y, 3)
end
end
popMatrix()
popMatrix()
if player.linearVelocity.x < 100 then
player:applyForce(vec2(100,0))
end
if CurrentTouch.state < 2 then
if CurrentTouch.y < HEIGHT/2 then
player.gravityScale = 3
elseif CurrentTouch.y > HEIGHT/2 then
player.gravityScale = 0.2
end
else
player.gravityScale = 0.4
end
end