As you know, the playing field is a grid. Because we will put a ‘wall’ around the playing field, we don’t start at position 0 but rather at position -1 to add squares. The squares in the field itself will have the type BT_BACKGROUND. The walls have the type BT_WALL. Because of this they will be put on the screen in a different color.
The code to add the necessary squares is shown below. Actually it is not that difficult to understand, but you might have no idea how to start on this. Read this code to gain a full understanding on how this works. Then add it to the create method.
for(int x = -1; x <= SQUARES_PER_ROW; x++)
{
for(int y = -1; y <= ROWS; y++)
{
5 if(x == -1 || y == -1 || x == SQUARES_PER_ROW || y == ROWS)
{
squares.New().create(VecI2(x, y), BT_WALL);
} else {
squares.New().create(VecI2(x, y), BT_BACKGROUND);
10 }
}
}
In the draw method you start with a black background. Next you show all the elements of the ‘squares’ container. Test your app and verify the result.