1
00:00:00,180 --> 00:00:06,090
Let's add in an event listener for starting the game so we've got our start game object that we created

2
00:00:06,090 --> 00:00:11,610
in the previous lesson, adding an event listener to that event listener that we're adding in is a click.

3
00:00:11,800 --> 00:00:13,200
We'll do an anonymous function.

4
00:00:13,500 --> 00:00:18,670
So containing all of the functionality that we need on the click within this set of code here.

5
00:00:19,050 --> 00:00:20,630
So what do we want to happen?

6
00:00:21,360 --> 00:00:27,960
And one of the things that we want is we want to take that start game object and update its style properties

7
00:00:28,200 --> 00:00:33,710
to be display none because we don't want the user to have the ability to click the button again.

8
00:00:34,110 --> 00:00:36,250
So only one click of that start button.

9
00:00:36,270 --> 00:00:37,140
So let's try that out.

10
00:00:37,410 --> 00:00:38,940
Click and it disappears.

11
00:00:38,970 --> 00:00:41,580
Still on the page, but it's being displayed none.

12
00:00:41,940 --> 00:00:50,130
Let's also create a random wait time, random time using math, random method from JavaScript.

13
00:00:50,760 --> 00:00:55,050
We can multiply it by 2000 and then we'll add 1000.

14
00:00:55,080 --> 00:01:01,680
So we always have at least 1000 milliseconds or one second before we start the game and we make the

15
00:01:01,680 --> 00:01:02,030
item.

16
00:01:02,400 --> 00:01:04,590
So setting up the set time out.

17
00:01:04,920 --> 00:01:11,490
And what this will do is this will execute a function or a code snippet after a specified delay so we

18
00:01:11,490 --> 00:01:19,740
can call it make item the function and random time is the time period that it's going to wait until

19
00:01:19,740 --> 00:01:20,910
it executes the function.

20
00:01:21,450 --> 00:01:27,620
So what this is going to do whenever we press that start button, it's going to select random time.

21
00:01:27,630 --> 00:01:34,380
So it could be anywhere from one to three seconds and it's going to start the process of having that

22
00:01:34,380 --> 00:01:38,880
element show up that we have to click and timing that element as well.

23
00:01:39,210 --> 00:01:44,370
Next, let's set up a function that will make the item, and this is where all of the gameplay will

24
00:01:44,370 --> 00:01:45,030
take place.

25
00:01:45,750 --> 00:01:52,260
So add that ability to start the game with the start button, set up a blank function to make the item.

26
00:01:52,980 --> 00:01:56,850
And coming up next, we'll show you how to complete the game and the gameplay.
