1
00:00:00,390 --> 00:00:05,430
This lesson, we're going to be introducing some fixes for the game and as we saw last time, we can

2
00:00:05,430 --> 00:00:08,760
keep producing multiple planes and we actually don't want that.

3
00:00:08,760 --> 00:00:13,110
We don't want the ability to produce more and more planes every time we hit the start button.

4
00:00:13,320 --> 00:00:19,320
So we need to hide this start button and this game message area until we actually need to make use of

5
00:00:19,320 --> 00:00:19,420
it.

6
00:00:19,440 --> 00:00:26,190
So let's introduce another class and we can just call that right and using display and setting it to

7
00:00:26,190 --> 00:00:26,450
none.

8
00:00:26,700 --> 00:00:32,560
And what we're going to do, we're going to add this class to that element when we hit start.

9
00:00:32,790 --> 00:00:36,430
So that's going to hide that message area until we need to make use of it.

10
00:00:36,510 --> 00:00:43,950
So we've got our A game message object that we created in the earlier lessons taking the class list

11
00:00:43,950 --> 00:00:44,550
method.

12
00:00:44,550 --> 00:00:50,950
And we've got one called ADD and that's the one that we need in order to add a class to that element.

13
00:00:50,970 --> 00:00:56,760
I'm also going to be updating some of the way the game message looks because it does look a little bit

14
00:00:56,760 --> 00:00:58,470
plain, just being words.

15
00:00:58,740 --> 00:01:04,460
So I wanted to update some of the values there as well as do a position absolute for it.

16
00:01:04,770 --> 00:01:07,810
So we have an option to move it around a bit if we need to.

17
00:01:08,340 --> 00:01:14,490
And also, we're going to set it off of the bottom or set it off off of the top as a percentage.

18
00:01:15,030 --> 00:01:19,530
So top 10 percent, we can do a left 20 percent.

19
00:01:19,530 --> 00:01:23,840
And that means that are which should be 60 percent to center our message.

20
00:01:24,210 --> 00:01:26,430
So that's 60 plus 20 or so.

21
00:01:26,460 --> 00:01:26,730
Right.

22
00:01:26,730 --> 00:01:28,740
20 would be one hundred percent as full.

23
00:01:28,770 --> 00:01:35,340
Also, text align center is always a good way to go, setting up the background color to distinguish

24
00:01:35,340 --> 00:01:35,510
it.

25
00:01:35,870 --> 00:01:39,600
I said it as Alice Blue for now, the font size.

26
00:01:39,600 --> 00:01:45,770
So the font is bigger, but we do to em and save that.

27
00:01:45,780 --> 00:01:51,360
So let's try that out and we'll see that we get this press here to start game and when we press it,

28
00:01:51,360 --> 00:01:53,970
it disappears so we can't actually press it again.

29
00:01:54,090 --> 00:01:57,230
And that's exactly what we want because we only want that one plane object.

30
00:01:57,240 --> 00:02:04,560
So let's do one more condition just to double check and make sure that we're not interfering with already

31
00:02:04,560 --> 00:02:05,910
existing gameplay.

32
00:02:06,240 --> 00:02:07,940
So doing player in play.

33
00:02:08,250 --> 00:02:14,670
And this is the only time while we're in play, if it's not in play, then that's when we create the

34
00:02:14,670 --> 00:02:15,160
new player.

35
00:02:15,180 --> 00:02:16,390
So let's try that one more time.

36
00:02:16,710 --> 00:02:20,640
So now I can keep pressing and I'm not producing a second plane.

37
00:02:21,120 --> 00:02:23,310
So there's a few other things that we need to still take care of.

38
00:02:23,310 --> 00:02:24,150
A few other bugs.

39
00:02:24,420 --> 00:02:27,390
Notice that the plane can go off screen so it's not good.

40
00:02:28,080 --> 00:02:30,630
So we need to create a bounding area for the plane.

41
00:02:30,840 --> 00:02:36,540
And that's going to be relatively easy to do because we're already checking to see if our arrow keys

42
00:02:36,540 --> 00:02:37,140
are up.

43
00:02:37,380 --> 00:02:43,700
And before we actually allow this action to take place, we can see the value of player Y.

44
00:02:44,010 --> 00:02:48,480
So taking arrow key up and the value of player Y.

45
00:02:49,350 --> 00:02:56,430
And make sure that it's greater than zero, and if it is, that we could subtract off of it and correspondingly

46
00:02:56,430 --> 00:03:03,480
as well, let's take this one and make sure that player Y is less then and we're going to set up two

47
00:03:03,480 --> 00:03:06,090
hundred because I don't want the plane going all the way down.

48
00:03:06,360 --> 00:03:12,030
So we're creating a boundary area for the plane to interact and moving it left.

49
00:03:12,060 --> 00:03:16,280
So we want to make sure that Player X is greater than zero.

50
00:03:17,280 --> 00:03:24,210
And this one here, we want to make sure that Player X is less than the offset of the game.

51
00:03:24,690 --> 00:03:30,960
So Player X is less than and this is where we're going to use some dynamic values.

52
00:03:31,260 --> 00:03:38,850
And being dynamic is always better because in case you change the area, the game area size, we can

53
00:03:38,850 --> 00:03:46,260
use that value that we saw earlier where we've got the offset with minus let's subtract 50 to account

54
00:03:46,260 --> 00:03:47,340
for the plane size.

55
00:03:47,520 --> 00:03:51,500
So we're going to make sure that the plane essentially can't run off the side of the screen.

56
00:03:52,320 --> 00:03:54,230
And one more bracket there.

57
00:03:54,240 --> 00:03:56,060
So let's refresh try that out.

58
00:03:56,400 --> 00:04:02,460
So now whenever we move over to the right, you see my right arrow in my left arrow is true, but I

59
00:04:02,460 --> 00:04:03,780
can't move any more to the right.

60
00:04:03,990 --> 00:04:08,610
I can't move any more to the top and I can't move any more to the bottom.

61
00:04:08,880 --> 00:04:14,310
And let's just make sure that our boundary box is working so it can't move any more over to the right

62
00:04:14,310 --> 00:04:14,760
hand side.

63
00:04:15,390 --> 00:04:16,100
So that's great.

64
00:04:16,110 --> 00:04:21,290
Now we've added in the boundaries for our plane to be able to move around and navigate with them.

65
00:04:21,540 --> 00:04:24,030
So go ahead and add this into your project as well.

66
00:04:24,330 --> 00:04:28,950
And coming up next, we're going to introduce some more of the gameplay that we need to take care of,

67
00:04:29,250 --> 00:04:34,740
including moving the plane automatically because we want the plane always automatically to be going

68
00:04:34,740 --> 00:04:37,350
forward, as well as trying to introduce some scoring.

69
00:04:37,350 --> 00:04:39,150
So that's still to come in the next lesson's.
