1
00:00:00,180 --> 00:00:05,730
Hey, now the fun part, and this is always a great idea to kind of play through the game, make sure

2
00:00:05,730 --> 00:00:10,260
that you've got all the functionality and it's working the way that you're expecting it to work.

3
00:00:10,480 --> 00:00:15,870
So make sure that everything is working, run through it a few times, make some tweaks and adjustments

4
00:00:15,870 --> 00:00:21,030
to the numbers, because this should be fully dynamic so that you can adjust how many lives you have,

5
00:00:21,150 --> 00:00:26,010
what the starting score is, starting positions, the speed of the ball and so on.

6
00:00:26,010 --> 00:00:31,160
So you can make all of these adjustments within the settings in order to properly test your gameplay.

7
00:00:31,200 --> 00:00:35,700
So the one thing that we did notice in the last lesson is that the paddle can still run off the screen.

8
00:00:35,880 --> 00:00:37,980
So this is a relatively simple fix.

9
00:00:38,190 --> 00:00:39,510
So let's do that right now.

10
00:00:39,630 --> 00:00:41,330
And that's before we subtract.

11
00:00:41,370 --> 00:00:49,650
We want to make sure that the paddle and the current offset so both the paddle and P current is greater

12
00:00:49,650 --> 00:00:50,520
than zero.

13
00:00:50,640 --> 00:00:53,610
So that should take care of it moving off the left hand side.

14
00:00:53,620 --> 00:00:55,020
So let's see how that works.

15
00:00:55,380 --> 00:00:57,470
So now we can't move off of the left hand side.

16
00:00:57,630 --> 00:00:59,430
We can still move off the right hand side.

17
00:00:59,580 --> 00:01:04,320
And this is a little bit trickier because once again, we do have to make some calculations here because

18
00:01:04,320 --> 00:01:12,780
the paddle right side and the position, the dimension of the width, we need to make a subtraction

19
00:01:12,780 --> 00:01:13,350
off that.

20
00:01:13,470 --> 00:01:14,480
So show you what I mean.

21
00:01:14,490 --> 00:01:19,790
So when we take our current position, remember, this is the offset left.

22
00:01:19,800 --> 00:01:23,610
So this is going to be that edge here on the left hand side of the paddle.

23
00:01:23,610 --> 00:01:29,100
And we want to take that and make sure that that is less than before.

24
00:01:29,100 --> 00:01:31,560
We increment it by five.

25
00:01:31,680 --> 00:01:39,270
We want to make sure that that is less than the container dim wit that will make sure that the left

26
00:01:39,270 --> 00:01:43,850
edge is can't go past here, but our paddle is still going to go off screen.

27
00:01:44,070 --> 00:01:51,030
So one more adjustment and that's going to be subtracting the paddle offset width and that will give

28
00:01:51,030 --> 00:01:52,440
us the width of the paddle.

29
00:01:52,530 --> 00:01:55,770
And we actually know that, but we want to make it a little bit more dynamic.

30
00:01:55,930 --> 00:02:02,850
So in this case, we can make it more dynamic when we do the subtraction and make sure that we are making

31
00:02:02,850 --> 00:02:04,050
the proper calculation.

32
00:02:04,050 --> 00:02:05,820
And I need one more rounded bracket there.

33
00:02:05,820 --> 00:02:11,250
I believe take our container with subtract the width of the paddle.

34
00:02:11,490 --> 00:02:14,250
So that should bring us to the edge point here.

35
00:02:14,400 --> 00:02:20,360
Subtract in the width of the paddle to here and we're checking to see if the current is past that point.

36
00:02:20,370 --> 00:02:24,120
So try that and make sure that we can't go past the edges.

37
00:02:24,300 --> 00:02:27,900
And I am pressing that Iraqi I'm not able to move past the edges.

38
00:02:28,050 --> 00:02:32,700
So everything seems to be working properly and again, play through the game, make sure you do have

39
00:02:32,700 --> 00:02:38,430
the functionality that you are looking for and any little minor tweaks or adjustments.

40
00:02:38,580 --> 00:02:44,010
You can adjust some of the values within the calculations to make sure that it is functioning properly

41
00:02:44,160 --> 00:02:46,170
as well as where you're setting up the bricks.

42
00:02:46,170 --> 00:02:51,930
You can adjust how many bricks you're setting up and just notice that we're not actually checking to

43
00:02:51,930 --> 00:02:57,000
see if there's no bricks on the screen to check to see if the game is over.

44
00:02:57,210 --> 00:03:03,840
So that was another quick tweak that we need to make sure that we have a way to reset the bricks where

45
00:03:03,900 --> 00:03:05,610
we are selecting all of the bricks.

46
00:03:05,880 --> 00:03:11,940
This is the ideal spot to check to see if the node list has a zero value so you can write in a condition

47
00:03:12,060 --> 00:03:15,660
checking to see if Brix length is equal to zero.

48
00:03:15,750 --> 00:03:17,750
So that means there's no bricks within the no.

49
00:03:17,790 --> 00:03:22,800
If we don't return anything in the node list from querying all the elements with brick, that means

50
00:03:22,800 --> 00:03:28,860
there's none available and actually the game should be over and we want to run our stopper function.

51
00:03:28,860 --> 00:03:31,020
So that will stop the ball from moving.

52
00:03:31,020 --> 00:03:36,240
And then we want to set up another set of bricks or we should set a value for the number of bricks that

53
00:03:36,240 --> 00:03:36,750
we're creating.

54
00:03:37,260 --> 00:03:41,040
Just check double checking to see within the setup if we've got that dynamically.

55
00:03:41,250 --> 00:03:44,190
And if not, then it should be dynamically generated.

56
00:03:44,400 --> 00:03:49,170
So we do have a set up of bricks, so let's create a value for it within the player.

57
00:03:49,170 --> 00:03:52,440
And we just call this NUM so this can be thirty.

58
00:03:52,440 --> 00:03:58,830
And then now whenever we want to set up the bricks, we can always have the setup of the bricks or we

59
00:03:58,830 --> 00:04:00,690
can increment that every time.

60
00:04:00,690 --> 00:04:04,260
So adding even more bricks or decrease in the number of bricks.

61
00:04:04,420 --> 00:04:10,170
So again, making it dynamic whenever the game is ending, we can update that.

62
00:04:10,170 --> 00:04:12,960
And whenever we're running out of bricks, we can update that as well.

63
00:04:13,350 --> 00:04:15,510
So we'll set up a new set of bricks.

64
00:04:15,870 --> 00:04:19,350
We're going to stop the ball from moving and we'll see how this works out.

65
00:04:19,560 --> 00:04:24,300
And I think initially what we'll probably do so because, of course, we are just testing.

66
00:04:24,480 --> 00:04:29,820
I'm only going to set up two bricks so that when we start the game, we get rid of both bricks and we

67
00:04:29,820 --> 00:04:34,200
should be able to relaunch and we see the new bricks are generated.

68
00:04:34,230 --> 00:04:35,130
So that's working.

69
00:04:35,130 --> 00:04:37,110
And this last one was a little bit tricky.

70
00:04:37,110 --> 00:04:42,930
So just make sure that you can constantly go through it and it produces new bricks and we see that the

71
00:04:42,930 --> 00:04:45,510
score is still the same, the lives are still the same.

72
00:04:45,510 --> 00:04:48,510
So none of that has been affected and nor should it have been so great.

73
00:04:48,630 --> 00:04:49,140
Next.

74
00:04:49,140 --> 00:04:54,060
Coming up, we're going to do a quick run through the code and a review of the code that we've writing

75
00:04:54,060 --> 00:04:55,350
in the earlier lessons.
