Howdy,
Just for a bit of fun, I’m thinking about making a very simple 2d particle system. It will essentially spit out different coloured pixels. However I have a few questions about the design for those of you who are more well-versed in computer science than me.
A lot, if not all of the examples I have found on the net treat each particle as an instance of a Particle class, which holds its own variables and has an update method. That’s all well and good, and makes sense, but wouldn’t having a method call for each particle in each run of the update loop introduce extra performance overhead?
I’m more inclined to hold all particle information within arrays, perhaps in a ParticleEmitter class. Then instead of calling update() on separate instances of Particle, it would just be a case of doing some basic operations on a few arrays.
So my question is, are my assumptions about the overhead of a method call correct, and would the difference in performance between the two designs be considerable or negligible??? (Keeping in mind there may be quite a few particles involved).
Cheers,
nerb.