Game level attribute vs table level attribute
I have a few templates that use a game level attribute to change the state of a character. It's an integer. This integer is connected to the main character. For example, when 0 the character stays in the middle of the screen not moving. When you first tap the screen it triggers the attribute and changes to 1 which starts the character bouncing as you tap. If you die the integer changes to 2 and you have to start over again.
My question is are attributes such as these better put in a table in general now? From what I understand the less game level attributes the better since there is less code that needs to be checked or fired off when the game starts. Also that tables are rock solid in what they do. On the same note, what are some of the most common attributes that would be better off put in tables? Thoughts?
Comments
....
There's no need to use a table for this. People sometimes get stuck on this idea of optimization but unless you're constraining a whole bunch of attributes, it really doesn't matter if you have 12 or 120.
I would definitely use a game attribute for an actor state such as you described.
There aren't "common" attributes but rather common reasons for using tables. Any time you get beyond a few attributes, you should use a table. So if you find yourself thinking, "I'll need 40 attributes for those 40 actors, STOP and use a table." Another use is when you want to organize or automate things. So if each player in your game needs to keep track of score, power level, money, health, etc., use a table row for each player and keep those values in columns in each row. Or if you need to do something 100 times, use a table and the Loop over Table behavior.
I rarely begin a project thinking I'll need a table. It's more often that I consider how many attributes I would need and then defer to a table. Another consideration is loading and saving and copying tables. With one or two attributes, it's not too much trouble to load and save and even store a copy. Beyond that, it's just silly to work with individual attributes. And by silly I mean a major pain. Tables save using a single behavior (Save Table), load automatically, and can be copied using a single behavior (Copy Table). Ahh, efficiency.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@tatiang thank you that makes it much clearer for me. So If I were making a plants vs zombies type game having any attribute associated with the characters in the game play listed in a table would be the most efficient and least painful coding due to the long list of characters and corresponding attributes. A bridge boy type game would be fine with game level attributes due to the small size of the project and coding. So the right tool for the job essentially. Of course you have to have a good tool kit so that you can use the proper tool when the time comes
Always insightful thank you for that!
Np, you forgot to click on "insightful" though to show appreciation