List Manager vs Hard Array Manager?

Monkey Archive Forums/Monkey Discussion/List Manager vs Hard Array Manager?

zoqfotpik(Posted 2012) [#1]
Does anyone use hard arrays to store objects?

With a wrapper / manager class, this method is no more unwieldy to work with than normal objects. For my particles, I am running a particle system class which contains a set of arrays for x, y, vx, vy, particle type, etc.

This is rather a mix of the old way of doing things back in the 1980s and the object oriented way. By having it as a class, you can inherit other particle system classes. But by using hard-sized arrays you don't need to worry about the garbage collector, and according to my timing experiments it's somewhat faster than having all of the particles represented as individual first-class objects with internal methods, even if the objects are pre-allocated and reused rather than being destroyed.

It's a very brute-force way of doing things, and sometimes brute force is good. Obviously you're losing some flexibility by doing it this way but with specialization, does it really matter?


Samah(Posted 2012) [#2]
This is essentially how the particle system in Diddy works. See this thread which talks about this topic:
http://www.monkeycoder.co.nz/Community/posts.php?topic=1842


zoqfotpik(Posted 2012) [#3]
I like the way you have them bound to emitters. Will look into doing that myself