Question: Write a program that creates a circle at a random point in a window. If the user clicks within the circle, it will disappear and
Write a program that creates a circle at a random point in a window. If the user clicks within the
circle, it will disappear and the program draws a new circle at a random point.
If the user does not click on the circle within a specified time interval:
The circle disappears,
Appears a message "You missed the circle! Game over! Click mouse to close the window."
The program terminates on next mouse click.
Sample outputs:
Pop a circle
Pop a circle
You missed the circle!
Game overl Click mouse to close the window.
You will need function randrange from the random library to generate a random coordinates of a
circle within the windows. If is the radius, width and height the dimensions of the window, than
generate a random center point of the circle with statements:
from random import randrange
center randrange width randrange height
The algorithm:
create window
while True:
create a circle at a random point within the window
delay # experiment with various delay intervals
if there is a mouse click:
break if the mouse click is not in the circle
break if there is no mouse click
display label for game over
wait for mouse click
close the window
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
