This lesson, we're going to be showing you how you can start the game play.
We need to set up a few more global variables in order to use them.
So let's grab and set up play area.
And this is an object where we can set certain values within it, variable to store the start time.
So set that one up and leave that blank just as start.
So we have something to fill in and we want to get the start time whenever the player starts playing.
So the players plus the start button, the game is in play.
And before we show any buttons or boxes, we need to log that start time.
And the start time is going to be coming from the system.
The computer system start time because it's browser based.
So whatever your computer time is on your computer that you're using, it will show that.
And for this example, we're going to be making use of JavaScript Dete method and within the method
we have a way to get the timestamp and the timestamp is get time, which records the number of milliseconds
since January 1st, 1970.
So if we have a time before 1970, are we going to see it's negative?
And if we have a time after 1970, you're going to see it's positive.
So if I had run here, we've got negative.
If I just do the date and if I hit run, this is going to give us the current number of milliseconds
that it has been since January 1st, 1970.
So you can go ahead and try this out for yourself.
You can go over to the MDN website, or you can just simply type in the new date and then get time within
your JavaScript.
And you can see that being rendered out.
And your time will obviously be different than mine because this is the number of milliseconds.
So this is constantly changing.
So if I click it one more time, you're going to see that now.
It's already updated.
It's been a bunch of milliseconds since I've been talking.
So let's bring this into our project.
And this is how we're going to grab the time that the player starts and using that start variable that
we've set up using DETE.
So creating a new date object in JavaScript and we can change those methods together.
So you have an option here.
You can do it separately and then use the moon landing like they did over here and we could use start
and then use start, get time.
But we're just going to chain them together to save a little bit of space on the statements and we're
going to use that get time.
So now it's going to log the current starting time in milliseconds and which is going to give us a starting
point and we can use that variable afterwards to record the finishing time.
So when we start, you can see that we get our time in milliseconds, the time and milliseconds.
So now it's recorded in the global variable start and we can make use of it within our game.
So the next thing that we want to do is we want to launch the circles showing up.
So I show you how to do that in the upcoming lesson.
We'll create another function for that and we're going to launch that using set time out so that it's
more unpredictable and the players actually not going to know when the circles are going to show up.
So go ahead and pause the video, add this into your code, add the date object into your code, get
the current time output into your console.
Get familiar with the date object in JavaScript.