This site requires JavaScript, please enable it in your browser!
Greenfoot back
alicija
alicija wrote ...

2014/2/8

Counter help!

alicija alicija

2014/2/8

#
I'm sure you have all heard of the new game "flappy bird." Anyways, my gaming teacher created his own version of flappy bird using green foot but he broke the code so that certain things don't work. Our task is to fix the game and to add upgrades, etc. I am currently having an issue adding a score counter. I need it so that the score goes up by one, as the character passes each pipe. Any ideas on how I would code this? Thanks
danpost danpost

2014/2/8

#
I have not heard of "flappy bird". I will presume that it is a one-directional (right to left) side-scroller (the character appears to go from left to right). There are different ways to make the score go up one each time the character passes a pipe. Using intersection with the pipes by itself will not work unless you incorporate a boolean to track the last state of intersection and compare it with the current state. Using the change in the differences in the x values of both the character and the pipe is another way (save the original x of character minus the x of the pipe; then after move, only if the original difference was less than zero and the current difference is not less than zero should the score be incremented). I do not know what speed your bird will be going and how wide the pipes are, but if not too fast and wide enough, then you should have no problem with these methods. Hope my presumption was correct and this helped.
You need to login to post a reply.