Instead of adding bricks to the list as they become visible, you could instead keep them all in the list like you have now, and simply have each one have a boolean variable for "visible." Then in the render call, you would choose whether to actually draw or not based on that variable. This way, each brick handles whether it draws or not. This method comes in handy in the future as well, as you get used to each class handling its own affairs. Technically, you have a bit of overhead calling those Render functions for them not to draw, but I think it is worth the organization purpose, and in this type of game it shouldn't affect anything anyway.
I have this bool variable named shown in the brick class
Problem is, The time interval for the next brick to shown
foreach (var brick in bricks)
{
if(timer >= 1.0f)
brick.shown = true;
}
foreach (var brick in bricks)
{
if(brick.shown)
brick.render()
}
The thing here is that the first loop will iterate all over the list before getting to the next loop to render. So its the same thing that will happen. The brick will just show instantly.
Edit. This seems to work but on different way
foreach (var brick in bricks) {
timer += (float)gameTime.ElapsedGameTime.TotalSeconds;
timecounter += (int)timer;
if (timer >= 5.0F) timer = 0F;
if(timecounter >= 5)
{
brick.shown = true;
timecounter = 0;
}
if (brick.shown)
{
brick.render(gameTime);
}
}
Problem with this code is that it randomly shows what brick show up and not one after the next brick on its left side.
This is my level
11111111
10000001
12222221
10000001
12222221
11222211
Should be the the brick will be rendered from left to right top to bottom. Something like that. Any ideas?