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

2013/2/17

Score----How do I do it?

Eli.A Eli.A

2013/2/17

#
I'm making a game where you shoot balloons. It works pretty well, but I want to now how you make it have a score. I have no idea how to do this. I now that in some other languages I know you have to make a variable to do it, but ihave no idea how to do it with Greenfoot. Feel free to ask for any of my code if you need it.
Gingervitis Gingervitis

2013/2/17

#
There is video that I watched that showed me how to count objects. You can find that video on this very website. Clicking on 'Documentation' will get you to that video.
tylers tylers

2013/2/17

#
have somthing like:
int balloonsPopped = 0;
then do this every time a balloon get popped:
balloonsPopped++;
danpost danpost

2013/2/17

#
tylers solution will work if you want to internally keep track of how many balloons have been popped. If you want to visibly display a running counter showing how many have been popped, you will need to create or import a Counter class, link it to the class that detects balloon popping and control it from there. NOTE: if only one counter object is going to be in your world, linking is not mandatory. The Counter class should be able to create and update the image (as the count changes) and have public method(s) to adjust the count value and to return the current value.
You need to login to post a reply.