How do I best store an RPG character's attributes?

Get help using Construct 2

Post » Mon Oct 19, 2015 6:51 am

I'm making an RPG and want to store several attributes for the character, from Name to Experience Level, to current EXP, Strength, etc. I'm trying to determine which of the following ways is best:
- Array
- Sprite Instance Variables
- Dictionary Keys
- Global Variables

I'm afraid to start using a ton of Global Variables, because I know that list will get very long very soon, and the character will never actually appear on screen (therefore will never be destroyed, and will be global itself). What do you think? I'm still honestly struggling with Dictionary Keys, because if you don't declare on each layout, you'll have to go hunting for the value each time.
B
14
S
5
Posts: 37
Reputation: 1,026

Post » Mon Oct 19, 2015 1:56 pm

I would look at Json. Either store it in webstorage (or is it called local storage now?) or a database.

Something like: http://gameprogrammingpatterns.com/type-object.html
{
"Troll": {
"health": 25,
"attack": "The troll hits you!"
},
"Troll Archer": {
"parent": "Troll",
"health": 0,
"attack": "The troll archer fires an arrow!"
},
"Troll Wizard": {
"parent": "Troll",
"health": 0,
"attack": "The troll wizard casts a spell on you!"
}
}


http://gamedev.stackexchange.com/questi ... store-data
http://gamedev.stackexchange.com/questi ... driven-rpg

http://www.penguinprogrammer.co.uk/rpg- ... roduction/

Then you can use rex_rainbow's Hash plugin to parse/manipulate it.
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,414
Reputation: 4,822

Post » Mon Oct 19, 2015 3:37 pm

Just use an array, or a dictionary. The array will sort faster in most cases, but it not as easy to understand. You can save both of them as json strings.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Sat Oct 24, 2015 6:24 am

Thanks, guys. I'll look into this.
B
14
S
5
Posts: 37
Reputation: 1,026


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Syazanie Amirin and 11 guests