Project 2.8: Click
Click on the image to score points
Create a program that displays at least one moving image
The image can move in any pattern you want. It should either bounce or wrap when it would attempt to leave the screen.
When the user clicks on the image, the image instantly teleports to a new, random location and the user earns a point
Your program must have a background that is also an image of your choice
At the top of the screen, you must display:
The user's current score
The amount of time left in seconds
The user starts with a maximum of 20 seconds (1200 frames)
When time is up...
The image should stop moving and not respond to clicks
You should display one of three messages to the user rating their performance.
Ex: An okay score might say, "Not Bad!" while a high score would say, "Great Job"
FAQ / Tips
Breaking It Up Into Steps
How do I detect if a user clicks in the image?
You'll need an if statement with four conditions all joined by AND statements:
mouseX > xPos
mouseX < xPos + your image's width
mouseY > yPos
mouseY < yPos + your image's height
You can find a much more detailed discussion of this in the Coder's Handbook on Mouseover and Clicks
How do I convert from frames to seconds?
There are 60 frames in a second. So... divide by 60.
How do I make my program "stop" when I hit the end
Don't think of it as stopping the movement. Rather, you'll only allow the movement to happen if there is time left. To put it plainly: you'll wrap a section of your code in an if statement that checks timeLeft.
EXAMPLE: RUNNING PROGRAMS
Click here to download a running version of the program. <TBD>