Rpg Statistics

0 favourites
  • 5 posts
From the Asset Store
Another 10 RPG Battle Themes for Your RPG, RTS, or Fantasy Title!
  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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 :-)

  • 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.

  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)