I have an object that will fire out projectiles, I was trying to use a list to spawn in the Rockets(projectiles) so I could delete them when they collide with an object. So I first create List<Rectangle> Rockets;
I then add in a function for the rockets to be spawned in and fired constantly:
if (Time > 0.2)
{
Time = 0;
Rockets.Add(new Rectangle((int)Position.X, (int)Position.Y, rocketTexture.Width, rocketTexture.Height));
}
I then try to update them so they will move across the screen by doing a foreach:
foreach (Rectangle r in Rockets)
{
}
Question
This is where I get stuck, how do I call upon the x and y value inside the list of each Rocket so i can move it across the screen?
I may be thinking too hard about this and there is an easier way to create a large amount of projectiles and have them despawn when colliding with a way or when they go too far.