There are few events in my game, like complete levels , complete puzzles , kill enemies and so on. Each such event will reward the player points and bonus powers. Now each "master" task (for example puzzles) can reward the player different points so the hierarchy can be big. How do I design such module ?


2 Answers 2


Take a look at this tutorial. You can implement acheivement easily and start there to change acheivement to a reward system pretty easily.



Well, points I imagine would be just a counter really?

If there is only one score, a total "Points" count, then just KISS and use an int, add points to it. If you want to show maybe the amount of points received at the end of the level, add up the different sub type of points and then add them to the total score at the end of the level in some fancy animation to make it more "fun(tm)".

As for knowing how much an enemy or puzzle is worth depends on how you represent those things in your game. If they are classes or loadable files, then just store inside of them how many points they're worth and again, add the values when those events occur such as "completed puzzle" or "enemy dead", grab the point value, add it.

As for powerups, you could define your player to have certain attributes, such as "speed 5" "jump height 10" "can fly? no", then each powerup could just have modifier values which increases or decreases those values. Like:

class Powerup {
    float speedMultiplier = 1f; // What value to multiply against speed
    float jumpMultiplier = 1f; // What value to multiply against jump

Powerup superJump = new Powerup();
superJump.jumpMultiplier = 4f;

Powerup superSpeed = new Powerup();
superSpeed.speedMultiplier = 4f;

Powerup activePowerup = null;
float baseSpeed = 5;
float baseJump = 10;

if(jump) {
    float height = baseJump;
    if(activePowerup!=null) height *= activePowerup.jumpMultiplier;

// etc

Then maybe you have a base player stat, then reference to the currently active powerup, and then a "working stat", which is the base stats multiplied by the powerup multipiers, which is what's used in the game.

Or something like that?

I suppose there's an infinite number of ways of doing it, but I think the important thing is to keep whatever you make simple, over engineering a solution for this would be probably the worse thing to do.

  • \$\begingroup\$ its to simple , i have to may of factors in my game i need pattern \$\endgroup\$
    – user3689
    Commented Apr 1, 2014 at 17:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .