# Allison Obourn
# CSC 110, Spring 20189
# Lecture 12

# Simulates the dropping of two balls from various heights.

from DrawingPanel import *

def main():
    panel = DrawingPanel(600, 600)
        
    ball1x = 100
    ball1y =   0  
    v01 = 25
    ball2x = 200  
    ball2y = 100  
    v02 = 15
        
    # draw the balls at each time increment
    for time in range(60):
        d = displacement(v01, 9.81, time)
        panel.fill_oval(ball1x, ball1y + d, 10, 10)

        d = displacement(v02, 9.81, time)
        panel.fill_oval(ball2x, ball2y + d, 10, 10)

        panel.sleep(50) # pauses for 50 miliseconds
        panel.clear() # erase everything

# takes the initial velocity, acceleration and time
# in seconds as parameters and returns the displacement
def displacement(v0, a, t):
    d = v0 * t + 0.5 * a * (t ** 2)
    return d


main()
