Just to chip in, I use a tactic very similar to princec:
- Typed uniform grids for fast collision detection.
- A long (ordered) list with all entities in the game.
This list has delayed addition and removal of entities (stored in a single queue).
Entities will have their spawn method called when they have become part of the entity list.
Entities will have their cleanup method called when they are no longer part of the entity list.
Thus entities are spawned and removed in order.
Another benefit is that the list of entities is stable throughout physics computation.
It works well under the assumption that the game objects stay in the game for a long time (several iterations).
But of course all methods have drawbacks
I used to use the same approach for all games, but I’m shifting towards more modular and individual designs.
As such my game engine is starting to more and more become a game library instead…