I am kinda new to Construct 2 (and loving it, btw) and I always try to keep my code (or events, for this particular matter) as clean and tidy as possible. I would like to know what is the best approach option for two particular cases I am facing in my development in terms of performance and efficiency.
Case 1: The Player variables
I have this Player object with many attributes (namely Health, Power and Speed). I have to access those attributes from many different layouts because they will be changed by equipping items on menus and will also affect the game itself, during combat. I figured that I can't set those as instances variables for the Player object because they will be changed on layouts where the Player object is not present.
Then, I can either:
- set those values as global variables,
- as a dictionary or,
- as an X-only array
(if there are any other ways to setting these up, please let me know).
And set them "on load finished" or on my first layout.
Case 2: The slot system
I am setting up a slot machine system. Once every X seconds, 3 variables will be randomly set and, depending on their combination, give the Player a special power. I have to set up those individual powers manually (789 powers to go! Woohoo!), but I have to store their names, properties, damage and other attributes somewhere.
I can either:
- set them as local variables as I create their functionality on a (very huge) event sheet,
- as an array, and access the array's properties when the slot machine triggers that specific power's index
- set them as global variables on a separated event sheet, import that into the "Powers" event sheet and access them there.
These "Powers" would be set on "layout start" when the game level finishes loading (I guess?)
My question is, for both cases, what would be the most efficient and clean approach?
Thanks in advance!