How do I properly track player statistics?

Just started using Construct 2? Post your questions here

Post » Thu Mar 13, 2014 5:01 pm

Hey all, just kind of playing around making simple games at the moment, and was wondering about player stats.

If I have a party-based game, with a few characters controlled by the main player, what is the best way to track their stats?

For example, if I have two characters with some stats:

Health
Resource
Strength
Speed
etc.

What is the best way to track these stats? I would need them to calculate when battle occurs, as well as when not in a state of battle, to see interactions with items that can be equipped, as well as using items in inventory to affect these stats (think health potions or perhaps speed potions). I would want to be aware of their values throughout the game. From my past programming experience (limited as it is) I know that having a ton of global variables isn't usually a good idea.

I know that one approach to tracking enemy stats is to use families because they won't be used outside of a combat instance, but I don't think this would work for what I am doing.
B
3
G
1
Posts: 9
Reputation: 318

Post » Thu Mar 13, 2014 5:54 pm

You could use instance variables. (If you select one of your characters in the properties panel you can add the instance variable.)

So each instance of an object has its own copy of the variable and keeps track of the value. (When you assign an instance variable to a family each instance of that family member keeps track of its own value.)

The only thing is if the instance is destroyed the values are lost. So if you want to keep the values for beyond the life of the instance you would want to use either an Array or a Dictionary.
B
17
S
4
G
3
Posts: 172
Reputation: 1,933


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 3 guests