1
00:00:00,450 --> 00:00:06,720
This lesson is going to be a quick fix, so the last lesson we realized that if we put in 30 bricks

2
00:00:06,720 --> 00:00:12,600
but our screen size doesn't accommodate 30 bricks, well, then we throw an error because or we should

3
00:00:12,600 --> 00:00:13,080
throw an error.

4
00:00:13,110 --> 00:00:14,420
We should stop creating the bricks.

5
00:00:14,430 --> 00:00:17,710
And in this case, the bricks have stopped being created around 16.

6
00:00:17,730 --> 00:00:19,290
So we shouldn't go past that.

7
00:00:19,440 --> 00:00:22,820
And when we do have a wider screen, we can accommodate 30.

8
00:00:23,010 --> 00:00:28,470
So we want to make it flexible enough that depending on the screen size, we can cut the number of bricks

9
00:00:28,710 --> 00:00:34,770
so we can add in a condition here where we're doing the set bricks and also maybe create one.

10
00:00:34,770 --> 00:00:38,430
We can call it skip and skip to false.

11
00:00:39,420 --> 00:00:43,590
And here, if we have Skip.

12
00:00:44,830 --> 00:00:49,660
Or if we have no Skipp, then that's when we create the brick, otherwise we're going to skip the step

13
00:00:49,660 --> 00:00:52,190
of creating the brick and we can let it run through the count.

14
00:00:52,540 --> 00:01:00,070
So over here is where we need to make sure that when role Y is greater than half the available container

15
00:01:00,070 --> 00:01:03,070
height, then that's what we need to stop creating bricks.

16
00:01:03,310 --> 00:01:04,670
So let's add that condition in.

17
00:01:05,110 --> 00:01:14,680
So if role Y is greater than con Dem height and so its height and it's going to be height divided by

18
00:01:14,680 --> 00:01:14,940
two.

19
00:01:15,520 --> 00:01:21,580
So let's wrap this in around the brackets and if it is greater than then we're going to send we're going

20
00:01:21,580 --> 00:01:23,310
to set Skipp to true.

21
00:01:24,340 --> 00:01:25,330
And that's all we need to do.

22
00:01:25,900 --> 00:01:28,960
So start the game and we see that we stop at 16.

23
00:01:29,110 --> 00:01:31,660
And if you are, bring this down a bit, you can adjust this.

24
00:01:31,840 --> 00:01:34,080
So you might not want to do exactly half.

25
00:01:34,090 --> 00:01:35,590
You might want to change that.

26
00:01:35,710 --> 00:01:38,020
But in this case, I think half works really well.

27
00:01:38,140 --> 00:01:43,960
And it gives us the ability to limit the number of bricks and also gives us the option to make it dynamic.

28
00:01:44,110 --> 00:01:46,360
So if we do have space, we do 30 bricks.

29
00:01:46,570 --> 00:01:52,510
And if we don't have space than we do 16 bricks or even smaller if we have even less space.

30
00:01:52,720 --> 00:01:56,290
So if we only have space for 12, we're only going to do 12 bricks.

31
00:01:56,560 --> 00:01:59,970
So it makes our game more dynamic and the sizing to be dynamic.

32
00:02:00,730 --> 00:02:03,970
So go ahead and add that quick fix in to your project.

33
00:02:04,300 --> 00:02:10,150
And coming up, we're going to continue to build out the gameplay and add some more advanced capabilities,

34
00:02:10,300 --> 00:02:16,990
such as moving the ball and obviously collision detection to detect if the ball is colliding with the

35
00:02:16,990 --> 00:02:21,770
paddle and colliding with the bricks and then taking the appropriate actions for that.

36
00:02:22,240 --> 00:02:25,450
So that is all still yet to come in the upcoming lessons.
