Hi GoToLoop, thanks for the help but even though I can find the code where you mentioned and wrote about score I dont know how to adapt that for it to work in my code in processing. Also was that code created to be run in processing because when I try to run it it compiles errors, Also is that written in the same language that I am writing my code in?
Regardless if you create a custom class for score or if it's just a simple variable, it needs to be triggered once for each enemy death. That is, at the same time a remove() happens.
Yh that makes sense thanks. So every time an enemy is removed I have to implement a score into the game. Im struggling to write the code for that and that is what I needed help for.
Do you already have some means to remove() an enemy from its container, or alternatively mark them as dead? Once you got that, it's as simple as adding ++score; there. :D
In the code ive provided above I used 'booleans' to remove enemies once theyve been hit but now I dont know how to add a score feature using code even though I understand how it needs to be done theoretically :
boolean alive() {
for (int i = 0; i < bullets.size(); i++) {
Bullet bullet = (Bullet) bullets.get(i);
if (bullet.x > x && bullet.x < x + pixelsize * 7 && bullet.y > y && bullet.y < y + 5 * pixelsize) {
//bullets.remove(i);
bullet.alive = false;
return false;
}
}
for (int i = 0; i < bullets.size(); i++) {
Bullet bullet = (Bullet) bullets.get(i);
if (bullet.alive == false) {
bullets.remove(i);
}
}
return true;
}
Ive seen the checkDeath() function and I do understand it but I know I keep repeating myself but I still dont know how to use that for my own game code. If you could start me off it would be much appreciated, thanks.
Answers
Make a Score class like i did in this little game: *-:)
Hi GoToLoop, thanks for the help but even though I can find the code where you mentioned and wrote about score I dont know how to adapt that for it to work in my code in processing. Also was that code created to be run in processing because when I try to run it it compiles errors, Also is that written in the same language that I am writing my code in?
Regardless if you create a custom class for score or if it's just a simple variable, it needs to be triggered once for each enemy death. That is, at the same time a remove() happens.
Yh that makes sense thanks. So every time an enemy is removed I have to implement a score into the game. Im struggling to write the code for that and that is what I needed help for.
Do you already have some means to remove() an enemy from its container, or alternatively mark them as dead? Once you got that, it's as simple as adding
++score;
there. :DCheck out function checkDeath() on this other online example: ;;)
http://studio.ProcessingTogether.com/sp/pad/export/ro.9K-kjhuONcJDZ
In the code ive provided above I used 'booleans' to remove enemies once theyve been hit but now I dont know how to add a score feature using code even though I understand how it needs to be done theoretically :
Ive seen the checkDeath() function and I do understand it but I know I keep repeating myself but I still dont know how to use that for my own game code. If you could start me off it would be much appreciated, thanks.
https://forum.Processing.org/two/discussion/15993/how-to-add-score-feature-to-my-game