1
00:00:00,060 --> 00:00:05,640
So I know the last lesson was fairly intense, but the good news is that now it's all smooth sailing.

2
00:00:05,820 --> 00:00:10,320
We've got all of the functionality that we need and now it's just a matter of making some minor tweaks,

3
00:00:10,320 --> 00:00:12,400
adjustments within our gameplay.

4
00:00:12,630 --> 00:00:17,340
We see that whenever we're dropping our bombs, if they're hitting our target, we're getting this crash

5
00:00:17,340 --> 00:00:17,820
value.

6
00:00:18,060 --> 00:00:23,840
And we know that once we get that, then that's a score we want to be able to score to the player.

7
00:00:24,120 --> 00:00:29,790
So let's update the player score and add in a value of 2000.

8
00:00:29,820 --> 00:00:35,940
Also, we want to remove out that base and recreate it somewhere else because now that one's been destroyed.

9
00:00:35,970 --> 00:00:41,510
So taking our player base, we need to move up to its parent element.

10
00:00:41,520 --> 00:00:48,000
So whatever the parent element is, and just as we did over here to move out the bomb, we need to navigate

11
00:00:48,000 --> 00:00:55,940
up to the parent element and then do the remove child and select our player base as the child.

12
00:00:56,040 --> 00:00:59,030
So that will remove it from our visual area.

13
00:00:59,280 --> 00:01:03,640
And we also need to take our bomb and remove that one as well.

14
00:01:03,660 --> 00:01:07,950
And then lastly, we need to make another enemy because we need to keep the game going.

15
00:01:08,190 --> 00:01:10,040
And we already have that function built.

16
00:01:10,380 --> 00:01:11,850
So taking that function.

17
00:01:11,860 --> 00:01:15,610
So instead of crash, we're just going to generate a brand new enemy.

18
00:01:15,660 --> 00:01:18,650
There's a few other things that we still probably need to take care of.

19
00:01:18,930 --> 00:01:23,560
So let's try the game out and we're going to see what else we need to tweak and adjust.

20
00:01:23,880 --> 00:01:29,990
So now the way that it should play, if I hit the target that we get a brand new one in our score increases.

21
00:01:30,030 --> 00:01:32,790
So so far that is working as expected.

22
00:01:32,790 --> 00:01:37,100
We can see that I am hitting the target and it is updating that value.

23
00:01:37,290 --> 00:01:38,700
The number six.

24
00:01:38,700 --> 00:01:43,260
So the bombs are outputting the value of how many are active.

25
00:01:43,270 --> 00:01:47,010
So maybe we don't want that to happen and we want to have a different value.

26
00:01:47,550 --> 00:01:49,770
So we could really easily add that in.

27
00:01:49,770 --> 00:01:57,060
We could count all of the bombs that have been added so we could do something like player bomb score

28
00:01:57,390 --> 00:01:58,610
and equal that.

29
00:01:59,250 --> 00:02:03,290
So just increment that and maybe that's the value that we can output.

30
00:02:03,540 --> 00:02:10,020
So every time the player has another drops, another bomb, that's just going to increase that bomb

31
00:02:10,020 --> 00:02:10,410
score.

32
00:02:10,680 --> 00:02:15,860
And that means that we need to set another value in here at zero.

33
00:02:16,290 --> 00:02:17,280
So let's try that out.

34
00:02:18,930 --> 00:02:24,150
So now we get one, two, three, four, and it's not counting how many active bombs we currently have

35
00:02:24,150 --> 00:02:24,980
in process.

36
00:02:25,590 --> 00:02:32,940
So the other thing, too, is that we wanted to make sure that when we make a bomb that this value of

37
00:02:32,940 --> 00:02:44,560
player active bomb is going to be less than what our bomb score is or total bombs is getting confused.

38
00:02:44,580 --> 00:02:46,350
Let me make that a little bit bigger.

39
00:02:47,100 --> 00:02:53,760
So we want to make sure that we're not able to we're only able to create them if this statement is true.

40
00:02:54,730 --> 00:03:01,030
So that means that we can only have two at a time on the screen, so let's try that now so we only have

41
00:03:01,030 --> 00:03:02,500
two out of time on the screen.

42
00:03:03,070 --> 00:03:07,470
And whenever we have those ones drop off, we can create more.

43
00:03:08,080 --> 00:03:11,620
So that's a way to adjust the number that are currently on the screen.

44
00:03:11,800 --> 00:03:16,450
If we want to have the ability to have more, we can implement that as well.

45
00:03:16,480 --> 00:03:19,890
So now we can have up to six on the screen at one time.

46
00:03:20,380 --> 00:03:24,690
So we also might want to introduce the number of levels of bombs.

47
00:03:25,000 --> 00:03:32,500
So let's do another one and we'll do level will have ten bombs or every time we make a new enemy that

48
00:03:32,500 --> 00:03:33,670
we're going to decrease.

49
00:03:33,670 --> 00:03:36,700
This value is less than zero.

50
00:03:37,240 --> 00:03:38,860
Then that means that we end the game.

51
00:03:39,170 --> 00:03:45,290
So we're not going to make an enemy that we just simply go out and we end game.

52
00:03:46,060 --> 00:03:47,290
So I have a function for that.

53
00:03:47,620 --> 00:03:56,170
And else we can continue to make more bases and actually bring this level down to just one and we'll

54
00:03:56,170 --> 00:03:57,280
just add that function.

55
00:03:57,280 --> 00:04:03,600
And so adding the function to end the game as we do need to have an end for the gameplay, of course.

56
00:04:04,270 --> 00:04:12,100
So adding in the console message and game over and we'll create will show the start button once again

57
00:04:12,100 --> 00:04:12,850
once it's over.

58
00:04:13,000 --> 00:04:14,370
So this one's a little hard to hit.

59
00:04:14,380 --> 00:04:19,720
So let's so I just skip over part of that in order to hit the actual target.

60
00:04:19,720 --> 00:04:21,190
But see, we've got the game over.

61
00:04:21,520 --> 00:04:25,990
So that means that we should stop the gameplay and we can set that to false.

62
00:04:26,350 --> 00:04:30,070
So that will stop our gameplay because we've got our inplay is true.

63
00:04:30,310 --> 00:04:34,030
So I set it to false and let's also set this to zero.

64
00:04:34,030 --> 00:04:35,500
So we left at one of the targets.

65
00:04:35,830 --> 00:04:43,210
So now we've got game over at stops and we can output a message back to the player so we can bring back

66
00:04:43,210 --> 00:04:44,370
the start screen.

67
00:04:44,380 --> 00:04:49,070
So the one that we added the class of height, so we'll remove hide from that element.

68
00:04:49,180 --> 00:04:52,200
So now if we hit it, we should get our start screen again.

69
00:04:52,600 --> 00:04:53,980
So we got our start screen again.

70
00:04:53,980 --> 00:04:55,120
We're able to start it again.

71
00:04:55,710 --> 00:04:56,760
Let's see what happens.

72
00:04:57,010 --> 00:05:00,460
So we didn't quite clear out all of our content.

73
00:05:00,460 --> 00:05:01,540
We made another plane.

74
00:05:01,900 --> 00:05:04,000
So that's another thing that we need to take care of.

75
00:05:04,180 --> 00:05:07,770
The next time we start out, we need to clear our game area.

76
00:05:08,350 --> 00:05:12,820
So let's take our game area and update the in HTML.

77
00:05:13,850 --> 00:05:18,230
And just make it blank, so sometimes you do need to play through a few times just to make sure that

78
00:05:18,230 --> 00:05:23,300
you've got all of the functionality that you want to make sure the inner turmoil is cleared and then

79
00:05:23,300 --> 00:05:24,170
we make the enemy.

80
00:05:24,170 --> 00:05:26,150
So you need to reverse the order of those.

81
00:05:26,910 --> 00:05:29,090
So let's move this value above it.

82
00:05:29,090 --> 00:05:35,720
So we're setting a value of player level so we can actually create at least one of the enemy bases.

83
00:05:37,630 --> 00:05:43,330
So we've got game over, we create another base game over, we create another base and we're able to

84
00:05:43,330 --> 00:05:44,300
continue our play.

85
00:05:44,500 --> 00:05:46,810
So now we can set of the player level.

86
00:05:46,840 --> 00:05:51,970
We can give her this console message that says game over and we can customize all of the rest of the

87
00:05:51,970 --> 00:05:53,380
content as needed.

88
00:05:53,440 --> 00:05:58,480
Let's make this bigger and we'll do another quick restart of it just to make sure that everything is

89
00:05:58,480 --> 00:05:59,530
working as needed.

90
00:06:00,010 --> 00:06:05,640
So now when we blow up and we kill off 10 of the enemy bases, that's when our game is over.

91
00:06:05,650 --> 00:06:10,720
And if you ever do need to get some of the values, you can, you can see it within the global object

92
00:06:10,720 --> 00:06:11,500
of player.

93
00:06:11,680 --> 00:06:13,890
So we've got our score value here.

94
00:06:14,080 --> 00:06:15,370
We've got our base.

95
00:06:15,370 --> 00:06:18,280
We've got our plane here, level three.

96
00:06:18,280 --> 00:06:21,870
That's how many enemies that how many bases we still have left.

97
00:06:22,240 --> 00:06:25,780
We have a bomb score of six active bombs of six.

98
00:06:26,020 --> 00:06:28,030
So there is a problem there that are active.

99
00:06:28,030 --> 00:06:29,610
Bombs aren't decreasing.

100
00:06:29,980 --> 00:06:33,370
So that's another bug that we need to still update and fix.

101
00:06:33,370 --> 00:06:38,800
And the problem here is that we're not decreasing the number of active bombs, but we are removing them

102
00:06:38,800 --> 00:06:40,120
from the play area.

103
00:06:40,390 --> 00:06:42,340
So we need to fix that as well.

104
00:06:42,340 --> 00:06:49,120
So we're moving them and we're taking away the active bomb here, but we're not taking it away over

105
00:06:49,120 --> 00:06:49,330
here.

106
00:06:49,330 --> 00:06:51,730
And that's where we're getting that inconsistent number.

107
00:06:52,450 --> 00:06:54,630
So let's try that again one more time.

108
00:06:55,030 --> 00:07:00,940
So now, whenever we hit the enemy base, we've got to make sure that are active bombs are adding up

109
00:07:00,940 --> 00:07:01,390
as well.

110
00:07:01,420 --> 00:07:06,250
So if we don't have any active bombs on the screen, it should always be back to zero.

111
00:07:06,460 --> 00:07:08,410
This is how many we've dropped so far.

112
00:07:08,680 --> 00:07:11,410
And this is we also have the total bomb.

113
00:07:11,430 --> 00:07:13,830
So that's our max that we can drop at any one time.

114
00:07:13,840 --> 00:07:18,700
And as you can see, once I start dropping some more, these values are going to be updating.

115
00:07:18,700 --> 00:07:22,540
If output player again, you're going to see that those values are changing.

116
00:07:22,570 --> 00:07:26,680
So go ahead and play through the game a few times, make sure that it is working as needed.

117
00:07:26,890 --> 00:07:31,000
And coming up next, we'll do a quick code review, an overview of the code that we've been working

118
00:07:31,000 --> 00:07:31,240
through.
