Storing Game Attributes in a Table - refer to the Table or to the Attribute?
In order to make it extremely convenient for me to tweak the game calculations, I was going to store all of the constants in a Table and refer calculations to it there, instead of writing constants directly into the equations.
My question is this: in the interest of game speed, is it better to refer to the table directly, or to update a global attribute to the table value?
- Table directly: Damage calculation would be (tablecellvalue(TB_Constant,1,2)*Self.Damage)
- Attribute: Damage calculation would be (Game.DamageMod*Self.Damage), and then I'd have an actor that updates the Game.DamageMod attribute to match tablecellvalue(TB_Constant,1,2)
Best Answer
-
Braydon_SFX Posts: 9,273
@TheAlchemyst said:
I'd prefer tables as well, but I'm expecting some pretty heavy calculations so I wanted to check. I know there are some... intricacies to what impacts game speed that are hard to tell from a beginner's perspectiveIt can get messy and complicated doing calculations in a table expression. If that's the case perhaps you want to use global variables. Again, it's up to you.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
Answers
I don't know if you'll see much difference if you see difference at all. I'd say you should go with your preference.
My preference would be to use tables.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
I'd prefer tables as well, but I'm expecting some pretty heavy calculations so I wanted to check. I know there are some... intricacies to what impacts game speed that are hard to tell from a beginner's perspective
What complications would that be? Being an Excel geek by day, I figured I could just do something like (tablecellvalue(TB_Constant,1,2)*Self.Damage)^(tablecellvalue(TB_Constant,1,3))-tablecellvalue(TB_Constant,1,4) or what have you and still be fine
If you use Excel a lot, then you would most likely spot errors in your expression. I don't use Excel much but do a lot of table expressions. If it's a long expression, sometimes I leave out a parenthesis or two. That's just me.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
http://forums.gamesalad.com/discussion/comment/523976/#Comment_523976
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User