Skip to main content
gamedev.net
🔒 Locked

Score Tracking

Started by JohnHurt 9 replies 1.4k views
Original Post
JohnHurt
JohnHurt
In a simple shoot-em-up game, what objects (conceptually speaking) would handle the game's scoring system? I'm trying to create a very simple game at the moment, but I want to get things arranged in a decent object-oriented way. So, for instance, the players weapon destroys an enemy, the enemy has a points value assigned to it. Where is this points value sent to? A global Score object?
programwizard
programwizard
If you have a class for handling variables that affect all parts of the game (e.g. score, game state, etc) I would send it to that. Otherwise, you could use whatever variable you wanted, or put it directly in the player class.
------------------------------Support the Blue Skies in Games Campaign!A blog... of sorts.As a general rule, if you don't have a general rule in your signature, you aren't as awesome as someone who does. General rules roxor teh big one one ones.
Bob Janova
Bob Janova
player.Score += target.PointsValue ... both properties.
rpg_code_master
rpg_code_master
Quote:
Original post by JohnHurtSo, for instance, the players weapon destroys an enemy, the enemy has a points value assigned to it. Where is this points value sent to? A global Score object?


I'd say the points should really go to the player who killed the enemy. That way if you ever have a multi-player aspect of the game, score keeping would be a lot easier.

Also, if you want to save your player's scores, check out http://www.YourHighScores.com for an easy, free way to save them online for everybody to use.
JohnHurt
JohnHurt
Quote:
Original post by rpg_code_master
I'd say the points should really go to the player who killed the enemy. That way if you ever have a multi-player aspect of the game, score keeping would be a lot easier.


So taking it down a level, what mechanism would you use to actually "send" the points from the target to the player - the only ways I can think of is if the target itself has a pointer to the player.

Another way maybe, would be for each entity to have a reference to some kind of containing "Level" object, and for the score to be handed around from there.

rpg_code_master
rpg_code_master
The best way to do this is to find out how you are doing things at the moment. Can you give a brief overview of how your objects interact etc...?

Thanks
JohnHurt
JohnHurt
At the moment all my entities reside in a scene manager, which is basically just a big linked list that gets updated and rendered.

Entities which are required to interect with each other (i.e. collide) are also inserted in Collision Groups (one for the player, enemies, weapons etc).

The collision groups are then given rules telling them with what they can interact with (for example, enemies are allowed to collide with the player, and the players weapons)
Bob Janova
Bob Janova
Well, an object's 'death' could potentially affect all sorts of different parts of the game. It could also be caused by something a long way away (or by nothing at all), so you can't just use your collision groups. So I think your main game module should get a message saying which entity just died, and what entity was the immediate cause of that death. That could be the player who pushed him last, or perhaps the rocket that killed him. Projectile and delayed-action (proximity mines, etc) weapons ought to fire active objects that maintain a record of who 'owns' them. Then the main module determines who to give the score to:
if(killer != null){ if(killer.Owner != null) killer.Owner.Score += target.Value; else killer.Score += target.Value;}
Peachy keen
Peachy keen
The last way i handled score, anything that died sent a message to the killer [just a return-to-sender on the 'attack' message that killed it] with a pointer to itself [which contained it's point value, and type, and everything], and the killer would send the score value to it's parent, or it's team, or whatever [in this case, score was experience, so things can improve]. Worked pretty smoothly, and made so it was easy to implement extra little on-death features, like each time creature A kills a creature of type B, it gains a temporary energy boost or something.
JohnHurt
JohnHurt
Thanks for the replies guys. I think I'll go with the owner/target idea, since I may want to have it so an enemy's weapon (or possibly death) can destroy another enemy.

I've thought of something much more complex though, for which I'll start a new thread at some point!
rpg_code_master
rpg_code_master
Be carful though, because technically the bullet's owner should be the weapon that shot it. It would be the weapon's owner, the player, that would be the entity you want. But if you have it in the bag, then cool [smile]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.