Say I have stored my projectiles somewhere and then I want to detonate it and deal damage to everyone around it, then I need access to all players and enemies and perhaps doodads to check the distance and calculate damage. But how do I access it? What's a general good advice? I thought of sending a pointer to the array of objects to be possible victims but then again I stored all objects in different arrays depending on what kind of object, and in different places and I then I took a break.
What are some general ways to structure this whole mess? I want to have some kind of decoupling of the responsibilities. For example the renderer class is separate from everything. I would like the objects to handle themselves like the projectile would do the exploding itself and doing damage in its own method or something similar.
I suppose the question is kind of unclear and I'm sorry for that, but I don't really know how to put it in a different way. I'm very thankful for any input I may receive!
EDIT: I was thinking of a system where every object handled everything themselves, collision detection and response, updating health points, animations and other possible events. I was looking at the SC2 map editor and it seems kind of complex but incredibly powerful and flexible. Are they doing something close to this?
Right now the code is kind of like containers of players, projectiles, enemies and the Game performs the calculations and updates, I suppose it would generally be a better idea to leave this to the individual objects considering they do different things in their updates. But then I imagine everything would be like a huge array of objects that are just looped through and have their Update method called, more or less. What are you thoughts on this?
Edited by Hannesnisula, 07 May 2012 - 08:50 AM.