Best way to handle multiple stats?

0 favourites
  • 8 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • What would be the best way to handle multiple statistics values for the player, such as HP, level, and EXP? I'm talking a moderately large number of stats, and in a RPG game I'm helping with; I counted and it's around +20 or so.

  • I personally like to use an array, and set it to be global. Of course, you need to document the XY coordinates for each stat, but if you plot it out right you can streamline it quite well.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I prefer using instance variable. It greatly helps with picking and is way more readable than simple array indexes. Also it's more in the logic of OOP.

    To keep these data through layouts, I would make the object global.

    To save/retrieve these data with webstorage or server database it could be interesting to have an action for serializing/unserializing these data into an XML or whatever string easily saveable.

    Ashley has some ideas maybe.

  • In CC I'd use an .INI or Hashtable. In C2...I dunno lol. I used to use arrays but tying a value with x,y coordinates is silly and I quickly learned there are better ways to go about this.

  • Yanns right instance vars are the way to go. You dont really have to make a bunch of global objects tho (unless you just need to) you can make 1 or 2 global objects that are solely for handling the task of data storage between layouts then relate whatever needed data to the new instances of the objects they belong to.

    Ive used this approach for years and ended up callin em Controller Objects

  • What do I do about stats that I do not want to reset if the player is destroyed?

  • Well the better solution is a mix of both.

    Store your initial values for player/NPCs/whatever in arrays, and on creation of said instance, fill the instance variables with the value out of the array.

    For the value you want to keep from an iteration to another, store them on death of the player in global variables, or an array which values are meant to change over time and apply them to the "newly" created player instance.

    Stuff like score, numbers of kills/death, etc... can be stored in global variables. Assuming you only have one player which is scoring/killing/dying.

  • <strike>Okay, I think I have it down but I'm encountering a visual glitch when I test it out. Project

    I only want the meter to empty out from the right side, and yet it's emptying out from both sides.</strike>

    Nevermind, fixed. It was the hotspot/origin point that was causing it.

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