from visual import * scene.width = 800 scene.height = 600 scene.autoscale = 0 scene.range = (100,100,100) scene.center = (0,40,0) ball = sphere(pos=(0,102,0),radius=2) ground = box(pos=(0,-1,0),size=(100,2,10)) building = box(size=(6,100,6),pos=(0,50,0),color=color.blue) gravity = 9.8 # m/s**2 velocityX = 6 # m/s seconds = 0 dt = .01 finished = False while not finished: rate(100) # go thru the loop no more than 100 times/s seconds += dt # position equation: y(t) = y0 + v0*t + .5 * a * t**2 ballY = 100 - .5 * gravity * seconds**2 ballX = velocityX * seconds ball.pos = vector(ballX,ballY,0) if ballY - 2 <= 0: finished = True print "seconds to drop: " + str(seconds) print "distance in the x direction: " + str(ballX)