We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have a scoreboard and life displayer in my program. I have a random object flying around the screen. I want the user to be able to press on the flying object and they will earn an extra life each time they click on it. What is the code I would need for this?
Answers
Please edit your post (gear icon in the top right corner of your post), select your code and hit ctrl+o to format your code. Make sure there is an empty line above and below your code.
Kf
You want an if check that is a "collision detection", based on the shape and location of your object compared to the location of the mouse when clicked.
http://www.jeffreythompson.org/collision-detection/table_of_contents.php
On click, IF a collision is detected THEN
lives++
http://www.jeffreythompson.org/collision-detection/point-rect.php
For example, check out Point / Rectangle collision examples if your target hit box is rectangular.
Thank you but I'm still unsure how to correctly type the collision code to detect my image "bulletbill.png" that moves randomly across the screen. Can you show me the code for that and where to put it? I'm very new to coding.