I'm developing a side-scrolling run'n'gun game (but with planes! :P). I'm an experienced coder, but new to game development.
When an enemy plane collides with a friendly missile, I start an explosion particle emitter on the enemy plane. The emitter is accessible as a private property of the plane object and its flow is controlled by the plane's update function (which is called from the game update function). The particle emitter's "render-update" method is called directly from the game renderer class.
I don't like these things:
- When the enemy plane is destroyed, I can't simply remove the object from my game's "enemyPlanes" array, as this would result in the particle sequence not completing itself.
- If I continue with this scheme, I have a very complex if statement in every execution of the render function, that will (a) check if the enemy is not shot down (b) check if the emitter is active (c) remove the plane as well as the emitter (if both previous conditions are met)
- The particle system is both accessed from the GameRenderer and from the plane object. I mean, I call something like
Is there a better way to do this?
EDIT: The library I'm using is libgdx (Java).