I'm new to stackover and this is my first ever post, so please be gentle :-)
I'm in the middle of developing a multi-level shooting game, and I'm questioning the best OOP design for my purposes, explicitly to manage the bullets.
Generally the game has multiple players and multiple enemies, each of which has a gun which fires bullets. There are bullet classes which manage multiple bullets well, their position, animation, rendering, etc, and these work fine.
My question is, am I better off instantiating an instance of these bullet classes per enemy, or am I better off instantiating one instance for the level which manages all bullets (irrespective of who fired it)?
The benefits of a single instance is that the bullet management and rendering can be optimised for them all at once, however they need additional state information so we remember which bullets belongs to who, how many bullets can exist for each enemy, etc, and it isn't as loosely coupled. The benefit of a separate instance per enemy is that it's neater and less state information needs to be stored per bullet, however they would be managed and rendered on separate calls for each enemy or player. Inter-bullet collisions would also prove more difficult, but luckily this isn't a requirement of this particular game.
Has anyone else written anything similar and how did you structure it? Which factors should I consider before deciding, and are there any game design principles for this?
Regards Nick