XP for multiple characters

0 favourites
  • 6 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • Hello!

    I'm making a game with multiple characters(selection screen), a leveling system and save games.

    Basically, I'd like to know the best option for:

    • Each character having it's own xp value
    • Including this value to a save data.
    • Ensuring the value persists among different layouts(levels).

    I was thinking of using an array, but I don't really get the whole 'grid' thing and it seems like more than I need. Are tables an option?

    I'd also rather not have a bunch of global variables for each new character I add.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The array will help keep things tidy. You might want to use an array for your entire character sheet. You can save and load an array really easy.

    For single values Webstorage would be the thing to look into. Then in your game rather than changing and checking variables, you can change and check web values.

    You can load and save arrays to webstorage too.

    If you are using node webkit you can write and read text files.

  • Instead of global variables you could also use instance variables, which seems far more logical because the variables are character related.

  • TwinTails, If you have a lot of values I would really recommend arrays. There is nothing to fear in those :) and it makes things rather easy. You could make text file for your self to keep track what is what. For example

    X=0... Character

    Y...

    1=name

    2=health

    3=mana

    4=xp

    etc...

    Specially if you are making RPG.

  • As an FYI, Array's are tables. They are an usually visually referenced as a spreadsheet(XY).

    I would suggest for the designer to use an array, and save the array to webstorage.

    Alternative is to use rojohounds "HASH" table plugin. Hash plugin behaves like a JS Object when wanting to access data.

    hero.name = Dread

    hero.level = 20

    hero.xp = 23054

    hero.weapons = {1:"pistols", 2:"rifle"}

    sidkick.name = Anders

    sidekick.level = 1

    sidekick.xp = 0

    sidekick.weapons = {1:"pisolts...}

    also because you are required to use a string based reference. You can do this.

    // initiatitae players adventure team

    Repeat 5

    --var PC = "character_" & loopindex &".";

    --Hash.set(PC & "XP", 0)

    but it also works great in reverse

    Repeat(size of Hash)

    -- var PC = hash.getkey()

    -- sprite.health = hash.getvalue(PC & ".health")

    also if you need to look at everyones data you can

    text.settext(hash.atkey("") )

    It does require some more sorting overhead to work in strings.

  • Thanks everyone :) I shall look into arrays and will use it for my character sheet.

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