""" ChapterAnimation/bounce2.py bounce: move a circle left - right """ from graphics import * winW,winH = 300,300 # window Width x Height def main(): win = GraphWin( "Demo: rolling car", winW, winH ) radius = 50 myc = Circle( Point(10,70), radius) myc.setFill( '#ffff00' ) myc.draw( win ) speed = 5 while True: myc.move(speed, 0 ) time.sleep(.05) if myc.getCenter().getX() > winW-radius or myc.getCenter().getX() < 0: speed = speed * -1 win.close() main()