Optimizing RPG variables

Get help using Construct 2

Post » Sat Jul 06, 2013 11:41 pm

So... I have seen a few people trying to make an RPG, and that made me start to wonder, "Where is everything stored?"

So, like I just said, if I were to start on such a massive project, where would I even begin to store all those player vitals, stats, inventory, progress

What are fine as instance variables? global variables? What are better off in a text file, array, XML, hash table, instance, etc.?

This isn't exactly my focus at the moment as I am not working on an RPG, but I would like to hold the information in a back pocket of sorts.
Heck, even if I am not working on an RPG, some elements may be useful for my project.

I feel like I may be asking a very broad question, so for anyone that can take the time to answer, thank you in advance.
B
8
S
2
Posts: 40
Reputation: 2,136

Post » Sat Jul 06, 2013 11:51 pm

I've been kind of thinking of the whole RPG element system. Anything that you want saved for a specific character, I would use as an instance variable for that sprite.

And anything that would be used multiple times at different layouts/maps, you would set that as a global variable.

By this, you would have multiple variables on one sprite, such as MaxHP, CurrentHP, MaxAtkDmg, etc.

Lets say you want multiplayer, you would want to use a global variable to kill slimes, so that if different players kills a slime almost at the same time, it would increment the same global variable. Its generally how you want to design it.

I don't know how the code is optimized in scirra, but an instance variable would be faster to use than a global variable in most cases.

I hope i am making sense, but that is what i came up with after dabbling in construct 2 for awhile.
B
6
Posts: 3
Reputation: 260

Post » Sun Jul 07, 2013 12:15 am

I would personally use a dictionary to store them. Its very easy to work with, meaning to get what you need, to store new stuff, update delete etc. And you don't have so many Global variables. Other than that you could also just make a "variable" holder. Like a small sprite and just add everything to it, and just make it global. nimos1002013-07-07 00:16:51
B
44
S
11
G
2
Posts: 1,181
Reputation: 6,801

Post » Sun Jul 07, 2013 1:00 am

[QUOTE=BoneyCheng]

I don't know how the code is optimized in scirra, but an instance variable would be faster to use than a global variable in most cases.

I hope i am making sense, but that is what i came up with after dabbling in construct 2 for awhile.[/QUOTE]

Where did you hear that ?

An instance variable is relatively heavier because it is stored for each instances of an object , and a global one is only stored once

Anyways , check out arrays
Whiteclaws2013-07-07 01:00:54
B
38
S
16
G
17
Posts: 2,230
Reputation: 17,220


Return to How do I....?

Who is online

Users browsing this forum: clissy09, Gravity17, hyem, LaurenceBedford, oosyrag, radu191289, raulcg1981 and 7 guests