1
00:00:00,760 --> 00:00:05,740
We've got our game playing and we don't have an end to it, so that's what we wanted to add in.

2
00:00:06,010 --> 00:00:12,850
And the objective is that if you miss three with a positive score, then your lives are going to decrease

3
00:00:12,850 --> 00:00:15,720
and eventually go down to zero and then the game is over.

4
00:00:15,760 --> 00:00:21,250
So whatever you've scored without scoring any of the negative ones, that's going to be your score.

5
00:00:21,400 --> 00:00:27,640
You could also do this on counting the different times you saw the different pop ups and having a limited

6
00:00:28,030 --> 00:00:29,830
number of those like 50 or 100.

7
00:00:30,070 --> 00:00:34,450
So there's a few different ways to make this game more interesting with an end to it, of course.

8
00:00:35,140 --> 00:00:41,620
So in this case, let's add that in and we're going to be adding it in to where we've got our start

9
00:00:41,630 --> 00:00:42,050
pop.

10
00:00:42,310 --> 00:00:50,080
So this is where we can look to see if the player missed it and within that time out.

11
00:00:50,090 --> 00:00:53,940
So make this a little bit bigger and within our timeout.

12
00:00:53,950 --> 00:00:56,320
So this, again, is that time out.

13
00:00:56,450 --> 00:01:00,340
So the player hasn't clicked the loss, then?

14
00:01:00,340 --> 00:01:01,000
That's fine.

15
00:01:01,390 --> 00:01:07,450
But if they haven't clicked a positive value one, then that's where they're going to lose one of the

16
00:01:07,450 --> 00:01:08,640
items or one of the lights.

17
00:01:09,190 --> 00:01:13,840
So adding that in and this is just going to be another condition here where we're going to check to

18
00:01:13,840 --> 00:01:17,050
see if whatever the value of Newport was.

19
00:01:17,300 --> 00:01:22,470
Remember, we're grabbing and setting that value in here so that we always can access it and use it.

20
00:01:22,900 --> 00:01:29,020
So if the new pop value is greater than zero, so that's anything that's a negative.

21
00:01:29,020 --> 00:01:30,150
So that's not going to be counted.

22
00:01:30,160 --> 00:01:30,820
So that's fine.

23
00:01:31,180 --> 00:01:36,250
And we see that that means that the player should lose some of the items.

24
00:01:36,280 --> 00:01:40,330
So the items were actually lives and we're just going to decrease it by one.

25
00:01:41,050 --> 00:01:44,350
And we should also update our score.

26
00:01:44,510 --> 00:01:46,590
So use our update score function.

27
00:01:47,530 --> 00:01:55,920
And next, let's check to see if the player items is less than or equal to zero.

28
00:01:56,320 --> 00:02:02,340
So that means the game's over and then we can run our game over function.

29
00:02:02,360 --> 00:02:07,290
So let's set up a function for that to keep that separated because this one is getting fairly long.

30
00:02:08,080 --> 00:02:17,170
So setting up our game over, function game over and this is what we want to happen when the game is

31
00:02:17,170 --> 00:02:17,500
over.

32
00:02:17,510 --> 00:02:22,990
So we've got our plate area and we've got our inplay.

33
00:02:23,830 --> 00:02:25,720
We've got our game.

34
00:02:28,500 --> 00:02:33,810
And it's actually player we had where we've got our game over, so that's the object that we've got

35
00:02:33,810 --> 00:02:34,020
that.

36
00:02:34,860 --> 00:02:37,250
So that's the game over value.

37
00:02:37,650 --> 00:02:39,600
So setting that to.

38
00:02:41,920 --> 00:02:48,220
True, so our game is now over, so that will stop it from creating New Pops.

39
00:02:50,270 --> 00:03:00,140
We need to update the play area and this is where we're toggling that class list and we're adding a

40
00:03:00,140 --> 00:03:01,700
class of visible.

41
00:03:05,130 --> 00:03:10,080
And we're flipping between the different pages, so this is going to give the player the ability to

42
00:03:10,080 --> 00:03:15,050
start the game again and the other one, the game board.

43
00:03:15,510 --> 00:03:17,070
So we've got our game.

44
00:03:17,370 --> 00:03:19,470
We're going to remove visible.

45
00:03:19,500 --> 00:03:20,940
So it's going to make it in.

46
00:03:23,470 --> 00:03:25,840
And then also documents.

47
00:03:28,130 --> 00:03:33,780
And query selector, and we want to update the text here.

48
00:03:33,830 --> 00:03:37,160
So going all the way up to our style.

49
00:03:37,610 --> 00:03:38,960
So we've got our.

50
00:03:40,410 --> 00:03:45,590
A new game, so instead of a new game, because we've already played the game, we want to update our

51
00:03:45,590 --> 00:03:47,750
text in the game over.

52
00:03:49,450 --> 00:03:59,690
So that one was new game class and inner text or inner turmoil with the inner text, and we'll just

53
00:04:00,010 --> 00:04:00,940
try again.

54
00:04:03,290 --> 00:04:04,610
And that's going to end our game.

55
00:04:04,790 --> 00:04:08,470
So whatever the score is, that's going to be the ending point of the score.

56
00:04:09,290 --> 00:04:10,370
So if you miss.

57
00:04:11,720 --> 00:04:14,570
Too many of the good ones, then your game is over.

58
00:04:14,810 --> 00:04:15,680
So let's try that out.

59
00:04:17,210 --> 00:04:19,190
So if you have missed one.

60
00:04:20,330 --> 00:04:22,190
I've missed you, I've missed.

61
00:04:23,360 --> 00:04:26,820
Three, and that was the last one, so our game is now officially over.

62
00:04:27,140 --> 00:04:28,910
So go ahead and add that in your project.

63
00:04:29,130 --> 00:04:30,890
Coming up next, we're going to clean this up.

64
00:04:30,890 --> 00:04:33,200
As you can see, we're covering the SCHAUS.

65
00:04:33,200 --> 00:04:34,970
We do want to be able to see that score.

66
00:04:35,120 --> 00:04:40,210
So we need to apply some success and just do some final tweaks and adjustments within the gameplay.

67
00:04:40,460 --> 00:04:41,870
So that's coming up in the next lesson.
