Write a program to animate a circle bouncing around a window. The basic idea is to start

Chapter 7, Problem 17

(choose chapter or problem)

Write a program to animate a circle bouncing around a window. The basic idea is to start the circle somewhere in the interior of the window. Use variables dx and dy (both initialized to 1) to control the movement of the circle. Use a large counted loop (say 10000 iterations), and each time through the loop move the circle using dx and dy . When the x-value of the center of the circle gets too high (it hits the edge), change dx to -1. When it gets too low, change dx back to 1. Use a similar approach for dy . Note: Your animation will probably run too fast. You can slow it down by using update from the graphics library with a rate parameters. For example, this loop will be limited to going around at a rate of 30 times per second: for i in range ( 10000) : 241 update (30) # pause so rate is not more than 30 times a second

Unfortunately, we don't have that question answered yet. But you can get it answered in just 5 hours by Logging in or Becoming a subscriber.

Becoming a subscriber
Or look for another answer

×

Login

Login or Sign up for access to all of our study tools and educational content!

Forgot password?
Register Now

×

Register

Sign up for access to all content on our site!

Or login if you already have an account

×

Reset password

If you have an active account we’ll send you an e-mail for password recovery

Or login if you have your password back