So, I’m jut wondering about something.
I know there are different ways to do diffferent things when programming, and I know there isn’t a “right” or “wrong” way to do things also.
I’ve been going through my game, and understanding a lot of things that I need to change, mainly to be more “object-oriented”.
Before, I was checking the score all through the level, and at the same time I checked if an enemy had 0 or less health, and what to do pretty much. So… remove from arraylist… clear screen if game is over… add score based on what is killed… ya.
My new idea was for each creature to detect if it is alive, and if it died, remove it from the arraylist through itself (being a creature).
So, my question is, if I want to keep track of the score of an individual player, and I want to do this through the player (map), would it be good practice to keep track of health/creatures dying/adding score to the player all within the level?
Here’s an example:
Level - creates all objects, draws all objects, checks for triggers to end the game (player dying).
Each Creature other than Player and other triggers - Checks if alive when being drawn, and if alive is drawn, otherwise is removed from arraylist.
At the moment I’m checking the helath for every creature through the level, but I’m just wondering if it’s good or bad practice to do everything through the level or through each object.
Again, the situation I’m referring to is this.
Player shoots enemy, enemy dies. What is the better way (better practice) to then add score to the player based on what score value that creature had.