This lesson is going to be a quick fix, so the last lesson we realized that if we put in 30 bricks
but our screen size doesn't accommodate 30 bricks, well, then we throw an error because or we should
throw an error.
We should stop creating the bricks.
And in this case, the bricks have stopped being created around 16.
So we shouldn't go past that.
And when we do have a wider screen, we can accommodate 30.
So we want to make it flexible enough that depending on the screen size, we can cut the number of bricks
so we can add in a condition here where we're doing the set bricks and also maybe create one.
We can call it skip and skip to false.
And here, if we have Skip.
Or if we have no Skipp, then that's when we create the brick, otherwise we're going to skip the step
of creating the brick and we can let it run through the count.
So over here is where we need to make sure that when role Y is greater than half the available container
height, then that's what we need to stop creating bricks.
So let's add that condition in.
So if role Y is greater than con Dem height and so its height and it's going to be height divided by
two.
So let's wrap this in around the brackets and if it is greater than then we're going to send we're going
to set Skipp to true.
And that's all we need to do.
So start the game and we see that we stop at 16.
And if you are, bring this down a bit, you can adjust this.
So you might not want to do exactly half.
You might want to change that.
But in this case, I think half works really well.
And it gives us the ability to limit the number of bricks and also gives us the option to make it dynamic.
So if we do have space, we do 30 bricks.
And if we don't have space than we do 16 bricks or even smaller if we have even less space.
So if we only have space for 12, we're only going to do 12 bricks.
So it makes our game more dynamic and the sizing to be dynamic.
So go ahead and add that quick fix in to your project.
And coming up, we're going to continue to build out the gameplay and add some more advanced capabilities,
such as moving the ball and obviously collision detection to detect if the ball is colliding with the
paddle and colliding with the bricks and then taking the appropriate actions for that.
So that is all still yet to come in the upcoming lessons.