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 key.
The layout of the graphics window:
Use method move to move a circle from the current position in the direction and in the
direction. Initially set and If a circle hits a vertical wall than change the horizontal direction
If the circle hits a horizontal wall, then change the vertical direction
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:
# is a radius, "width" is the width of the window
circ.getCenter
if or width
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
