Pythons Bouncing Ball & Dancing Daisy

from graphics import *

from time import sleep

W, H = 400, 400

r = 10


win = GraphWin('Bouncing Ball ', W, H, autoflush = False)

win.setCoords(0, 0 , 100, 100)

win.setBackground('black')



ball = Circle(Point(50, r), r)

ball.setFill('purple')

ball.draw(win)


daisy = Image(Point(20,30), 'daisy.png')

daisy.draw(win)


for i in range(10):

    for i in range(int(10-2*r)):

            daisy.move(1,0)

            update(40)

            

            

    for i in range(int(10+ 2*r)):

            daisy.move(1, 0)

            update(40)

            

for i in range(10):

    for i in range(int(100- 2*r)):

        ball.move(0, 1)

        update(40)#unit of frames per second 

    

    ball.setFill('pink')

    

    point = win.getMouse()

    

    for i in range(int(60+ 2*r)):

        ball.move(0, -1)

        update(40)#unit of frames per second 

        

        ball.setFill('purple')

    


win.close()



0 Kudos

Comments

Displaying 0 of 0 comments ( View all | Add Comment )