We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am making a game where I have a moving ice cream cone at the bottom of the screen that can be controlled using the left and right arrow keys. The point of the game is to catch randomly spawning ice cream scoops that fall from the top of the window. When the cone checks if the ice cream has hit, it increases the score. If it misses, then it is game over.
Problem: When the ice cream falls from the top of the screen and the player successfully "catches" it, I want the ice cream to stay on the cone so that as the player continues to catch new ice cream scoops, they will stack on top of one another.
Answers
When the ice scoop is caught, mark it as caught. Draw caught scoops with the same X position as your cone.
It is hard to help you beyond that because you have not posted some example code showing your issue.
Well, as has been said when you have a class
iceCreamScoop
and is marked as caught (boolean caught = false;
set totrue
) then set it'sX
to the x of the cone (with a randomoffsetX = random(-7,7);
maybe which is constant once it is set as property of the scoop)The cone can also have a
yForCaughtScoop
which decreases with every caught scoop: yForCaughtScoop = yForCaughtScoop - 7; which is passed to the scoop;-)
@TFGuy44, how do I post example code, I was going to but I didn't know how.
https://forum.processing.org/two/discussion/8045/how-to-format-code-and-text#latest
In short. ctrl-T in PDE to ident the code. Copy, leave one empty line before and one after, paste it , select code and hit ctrl-o.
Code is below:
and? have you done what we said? does it work?
yes, thanks. @Chrisir @TfGuy44
please come back when you need help