Rpg Statistics

Get help using Construct 2

Post » Sun Jan 27, 2013 8:10 pm

Hello

Sorry if this has been solved already, but the quick check i did of the Faq did not provide to much enlightenment.

I'm having a go at making a text based game, and i want to add some rpg style elements to it such as strength and speed etc... I could put these as global variables but I'm sure i remember from a guide to programming that this was bad practice, so my question is this:

Is there a more efficient way to record values such as statistics for a character in a game?

I regret to say that i am a complete novice at this, i know about arrays and my gut tells me that they would be a good way to do it, but my brain seams to go hide in a small hole when i try to get to grips with them.

Thank you in advance

Fullhouseofaces
B
3
Posts: 3
Reputation: 281

Post » Sun Jan 27, 2013 9:01 pm

I recommend you take a look into instance variables. They are variables specific to one instance of object (single character for example). In my opinion they are the best way to go here :-)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Sun Jan 27, 2013 9:13 pm

In my current project (not an RPG per se, but a game that handles stats in much the same way) I use a bit of everything: Base stats are stored in local variables; upgrades to those stats are stored in arrays; anything that I need global access to even when the player isn't in the layout (in your case, stats like XP or gold) are stored as global variables.

There's no universal wrong way or right way to store the information that you need - it just depends on the situation. I'd suggest that you start off with what you know. Arrays seemed like a weird, foreign concept to me when I started with Construct two months ago, and now I'm loving how useful they are. As my project has progressed and become more complex, I've grown to use the tools available and find better ways to manage things in my game, and I'll continue to develop new skills. I'm sure you can do the same, too.
B
56
S
15
G
10
Posts: 910
Reputation: 11,942

Post » Sun Jan 27, 2013 9:17 pm

Hello

Thank you for the reply vee41.

I tried using instance variables in the tutorial, i aimed to make the monsters get gradually tougher. However every time i a new one spawned it would have the base statistics and not the modified ones, forcing me to use global variables as a multiplier for their health when they spawned.

However with what i have planing instance variables would probably work. Once i have something to show for my efforts i'll report back.

Regards

Fullhouseofaces

Edit: Thank you for the advise and encouragement as well GeometriX, hopefully one day i'll tame the idea of arrays in my head. Fullhouseofaces2013-01-27 21:20:19
B
3
Posts: 3
Reputation: 281

Post » Mon Jan 28, 2013 1:11 am

@Fullhouseofaces - Don't forget dictionaries! I completely missed them when I made my RPG saving system and it would have saved me a whole lot of time.

If you want to add 5 to strength for example, just go to dictionary > set key 'strength' to dictionary.get("strength")+5.

The main point of using dictionaries (or arrays) is that you can save them .asJSON, which makes saving your game far simpler! If you do everything with variables, you will run into big time trouble when it comes to saving your game.
B
27
S
8
G
5
Posts: 429
Reputation: 6,902


Return to How do I....?

Who is online

Users browsing this forum: Magistross, mallorcaredes, PavleNikolic and 27 guests