1
00:00:00,420 --> 00:00:06,900
This lesson I'm going to be adding in some global variables so that we can track the user's progress

2
00:00:07,020 --> 00:00:13,960
as well as track the sequence that's being initiated by the computer that the player has to match.

3
00:00:14,370 --> 00:00:19,860
So that will give us two sequences and give us the ability to compare those two sequences to see if

4
00:00:19,860 --> 00:00:21,830
the player got the sequence right.

5
00:00:22,080 --> 00:00:25,890
And in this case, we're going to need to set up some global variables.

6
00:00:26,820 --> 00:00:29,930
So setting up and we're going to call one game clicks.

7
00:00:30,420 --> 00:00:41,250
So this will be an array that the player can use or the game can use to store all of the clickable array

8
00:00:41,550 --> 00:00:42,810
of colors.

9
00:00:43,200 --> 00:00:45,330
And next, let's set up another one.

10
00:00:45,360 --> 00:00:49,650
So this is user clicks and another blank array.

11
00:00:49,860 --> 00:00:56,910
And we're going to be populating these as the user and as the game makes the sequences that we need

12
00:00:56,910 --> 00:00:57,380
to follow.

13
00:00:57,870 --> 00:01:03,570
We also want to set one up where we'll call it in play and set that to false.

14
00:01:03,990 --> 00:01:07,500
So this will give us the ability to enable and disable the gameplay.

15
00:01:10,000 --> 00:01:16,550
And one more where we've got our plate number, so this is how many colors we're going to show.

16
00:01:16,810 --> 00:01:21,180
So the more color, the more the player gets them right.

17
00:01:21,220 --> 00:01:22,750
We're going to increase this number.

18
00:01:22,930 --> 00:01:27,180
So the more colors they're going to have to follow to move to the next part of the game.

19
00:01:27,220 --> 00:01:30,040
So it's going to keep getting harder and harder, essentially.

20
00:01:31,160 --> 00:01:34,580
So now, instead of the having the button.

21
00:01:36,310 --> 00:01:44,680
Just go works, we're going to check to see if the inplay is false, because we don't want the player

22
00:01:44,680 --> 00:01:46,120
to be able to restart.

23
00:01:47,500 --> 00:01:52,240
We're going to check to see if the inplay is false and if the inplay is false.

24
00:01:52,520 --> 00:01:58,200
We're going to run the function player and that's going to essentially set up our player area.

25
00:01:59,200 --> 00:02:04,810
So setting up that function player, we're going to first take the button object.

26
00:02:04,960 --> 00:02:13,120
So this is the start button here and we're going to play a property of disabled to it and set that value

27
00:02:13,120 --> 00:02:13,660
to true.

28
00:02:14,020 --> 00:02:17,200
So that will disable the ability to keep pressing that start button.

29
00:02:17,470 --> 00:02:21,160
So they're not going to be able to press the start button anymore after this is launched.

30
00:02:21,160 --> 00:02:25,720
And I'm also going to take these two arrays and I'm going to make sure that there's nothing in them.

31
00:02:25,720 --> 00:02:26,690
So it's cleaning out.

32
00:02:26,980 --> 00:02:32,860
So essentially it's going to launch a new game sequence and give the player the ability to create their

33
00:02:33,020 --> 00:02:33,940
user sequence.

34
00:02:34,600 --> 00:02:35,560
So let's try that out.

35
00:02:36,070 --> 00:02:40,570
So when we hit start, we can only hit at one time and then it's disabled.

36
00:02:41,810 --> 00:02:48,230
So ready to start building out the sequences and the next thing that we need to do is we need to run

37
00:02:48,260 --> 00:02:52,260
the sequence, create the sequence that the player has to follow.

38
00:02:52,970 --> 00:03:00,110
So let's set up a function for that so we can call it run sequence and we don't need anything else within

39
00:03:00,110 --> 00:03:00,710
that function.

40
00:03:01,490 --> 00:03:05,030
And the going down here, I'm actually going to move up this event.

41
00:03:05,030 --> 00:03:06,890
Listener So they're both together.

42
00:03:07,640 --> 00:03:16,340
And now let's create a function that will run the sequence and we don't need to pass any arguments in

43
00:03:16,340 --> 00:03:22,580
there because that number that we're going to be going by is already a global variable.

44
00:03:22,580 --> 00:03:24,560
So this play is a global value.

45
00:03:25,140 --> 00:03:30,170
Let's go down to where we were tracking the clicks, where we've got that checked answer.

46
00:03:30,320 --> 00:03:36,000
And now that we've got the inplay, we need to check to make sure that the game is in place.

47
00:03:36,200 --> 00:03:39,980
Otherwise, we're not going to allow clicks on those elements.

48
00:03:40,580 --> 00:03:42,410
So we make sure that it is in play.

49
00:03:42,740 --> 00:03:50,090
And if it is in play, then we can get that target as well as we can output into the console and we

50
00:03:50,090 --> 00:03:55,770
can take user clicks into the array or value into the array and taking the element.

51
00:03:55,790 --> 00:04:01,490
So the same one that we're outputting and just outputting that might color into the user clicks and

52
00:04:01,490 --> 00:04:04,340
we can now also console log out the user.

53
00:04:04,880 --> 00:04:08,660
And before we try that out, let's put the in sequence.

54
00:04:09,020 --> 00:04:12,420
So set in play and we're going to set and play to true.

55
00:04:12,980 --> 00:04:14,390
So when you hit start.

56
00:04:14,420 --> 00:04:15,380
So let's make this bigger.

57
00:04:15,740 --> 00:04:17,300
So we hit start right now.

58
00:04:17,300 --> 00:04:18,260
You can click on it.

59
00:04:18,260 --> 00:04:24,230
It's not adding anything in when we hit start that we can see that we're actually adding in and we're

60
00:04:24,230 --> 00:04:27,730
building out that sequence and you can see that's built out into the array.

61
00:04:28,070 --> 00:04:34,790
So coming up next, we need to generate a sequence as well from the computer and as well we need to

62
00:04:34,910 --> 00:04:37,900
light up these squares as we're clicking them.

63
00:04:38,060 --> 00:04:43,250
So the next lesson I'm going to show you how we can light up these squares to indicate that they've

64
00:04:43,250 --> 00:04:44,090
been clicked.

65
00:04:44,090 --> 00:04:45,980
So that's still to come in the upcoming lesson.
