require "physics"
H = platform.window:height()
W = platform.window:width()
dt = 0.01
velX = 0
velY = 0
posX = W/2
posY = 0
mass = 100
gravity = 100
space = physics.Space()
space:setGravity(physics.Vect(0, gravity))
newBody = physics.Body(mass, 0)
newBody:setVel(physics.Vect(velX, velY))
newBody:setPos(physics.Vect(posX, posY))
space:addBody(newBody)
function on.paint(gc)
fillCircleCenter(posX, posY, W/10, 0x000000, gc)
end
function on.timer()
space:step(dt)
pos = newBody:pos()
posY = pos:y()
if posY > H then timer.stop() end
platform.window:invalidate()
end
function on.enterKey()
timer.start(dt)
end
function fillCircleCenter(cx, cy, radius, color, gc)
gc:setColorRGB(color)
gc:fillArc(cx - radius, cy - radius, radius + radius, radius + radius, 0, 360)
end