# Moving circle; Animate a circle... from myro import * from random import * def main(): # create and draw the graphics window winWidth = winHeight = 500 w = GraphWin("Bouncing Circle", winWidth, winHeight) w.setBackground("white") # Create a red circle radius = 25 c = Circle(Point(53, 250), radius) c.setFill("red") c.draw(w) # Animate it dx = dy = 3 while timeRemaining(15): # move the circle c.move(dx, dy) # make sure it is within bounds center = c.getCenter() cx, cy = center.getX(), center.getY() if (cx+radius >= winWidth) or (cx-radius <= 0): dx = -dx if (cy+radius >= winHeight) or (cy-radius <= 0): dy = -dy wait(0.1) main()