ruskul wrote:Sethmaster wrote:In game, I am using a combination of arrays and dictionaries to keep track of all the data in my SRPG.
To load external data into those data storage, I am using csv files which is load straight into the arrays.
Here's a expert tip, don't ever compute long formulas (such as sorting or attack formula) straight using variables from a sprite object, especially when you have many of them presence.
Get the values from those variables, put them into arrays, global/local variables or dictionaries before calculating it.
Even better is if you don't put any computation variable on sprites and just put them in arrays/dictionaries beforehand.
You will find everything will run far smoother.
I am having difficulty understanding what you mean by this? What is wrong with using a variable off of a sprite? What is the advantage of copying it to the array before computing?
I am unsure on how to explain in detail but the short version is that when you retrieve value from a sprite object, there is a bit of overhead, vastly more than data storage object. It is not noticeable if you are not computing anything difficult or a lot. The overhead accumulate as you parse through more sprites/objects for data for computation. And if you run several loops of it in a single tick, hanging is concern if you set 60 fps as your minimum framerate (as I do).
For my game, the AI for each enemy run through thousands for simulation to achieve the optimal round plan based on their given AI archetype. So, I can see the difference quite clearly.
There is a huge difference in speed and smoothness parsing through rows in arrays or keys in dictionaries than going through each individual sprites for their variables