XP for multiple characters

Get help using Construct 2

Post » Fri Oct 11, 2013 1:07 pm

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.
B
25
S
6
G
3
Posts: 197
Reputation: 3,355

Post » Fri Oct 11, 2013 3:23 pm

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.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Fri Oct 11, 2013 3:33 pm

Instead of global variables you could also use instance variables, which seems far more logical because the variables are character related.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Oct 11, 2013 3:46 pm

@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.
B
34
S
9
G
3
Posts: 517
Reputation: 5,276

Post » Fri Oct 11, 2013 4:02 pm

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.
B
92
S
18
G
9
Posts: 2,455
Reputation: 15,113

Post » Fri Oct 11, 2013 6:25 pm

Thanks everyone :) I shall look into arrays and will use it for my character sheet.
B
25
S
6
G
3
Posts: 197
Reputation: 3,355


Return to How do I....?

Who is online

Users browsing this forum: pegasus6464 and 25 guests