Hi. I'm making a space game and I need the spaceship to shoot bullets. So in order to make this happen I need a collection which can allow the following:
1.Adding an object (so that we can shoot new bullets)
2.Looping through and modifying all the objects (so that we can change the positions of the bullets)
3.Removing an object that meets a certain condition (so that we can remove all bullets which have left the game limits)
At first I thought of using a List<> but the problem with it is that it doesn't allow looping through and modifying the objects (#2) since you can't assign to an iteration variable when using a foreach loop.
Using a regular array doesn't solve the problem either because it's hell trying to remove only certain objects from it (#3), although it is possible (but very ineffective and troublesome).
So is there a collection that can do all the three things I mentioned or if there isn't what is the easiest way to implement such thing?