1
\$\begingroup\$

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 ?

\$\endgroup\$
2
\$\begingroup\$

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

http://gamedevelopment.tutsplus.com/tutorials/how-to-code-unlockable-achievements-for-your-game-a-simple-approach--gamedev-6012

\$\endgroup\$
1
\$\begingroup\$

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.