Question: Write a program that creates a window with a circle that bounces from the window walls. The program terminates when the user hits q

Write a program that creates a window with a circle that bounces from the window walls. The
program terminates when the user hits "q" key.
The layout of the graphics window:
Use method move (dx,dy) to move a circle from the current position dx in the x direction and dy in the y
direction. Initially set dx=1 and dy=1. If a circle hits a vertical wall than change the horizontal direction
(dx=-dx). If the circle hits a horizontal wall, then change the vertical direction (dy=-dy.
The circle will hit a wall if the center of the circle is within radius distance of the wall. Use method
getCenter() to obtain a point which is the center of the circle. The following code will bounce the circle
from a vertical wall:
# r is a radius, "width" is the width of the window
c= circ.getCenter ()
if ((c*getx()-r)0) or width
 Write a program that creates a window with a circle that

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!