Hey!
I am currently trying to wrap my head around creating a small Sidescrolling Shooter.
What I can't figure out is what code to use for the shots/projectiles. The goal is obviously to despawn a projectile once it hit a target, so I figured I have to get the bounding boxes of every enemy on the screen and every projectile and test the collision through
intersects.
The next step is to despawn the projectile.
So overall, I thought of using a list or vector to contain all of the possibly shot projectiles and maybe allocating additional memory if somehow more projectiles than expected are on the screen at the same time. But despawning the projectiles really gives me trouble, since with a vect I would constantly be erasing elements right in the middle of it, resulting in horrible performance drops (I suppose).
I've been trying to find source codes of other sidescroller games to compare the ideas but tough luck.
So yeah, if there happens to be a super-efficient way of implementing shots, please tell me