This is the lesson we're going to take a look at the game that we've been building out in the earlier
lessons and see how we can make it better.
So so far, we have a basic game play area.
We have an element that we create using JavaScript.
So this is created on the fly and the objective of the game.
It's very simple and straightforward to move around your mouse cursor in order to get on top of this
element that keeps moving around all over the screen.
And so we want to move on top of it and we want to have the ability to maybe click on it.
And we have that option already added in, but we're not tracking any scoring.
So the score could make this game more interesting.
So let's go ahead and introduce that into our game.
So we're going to have a great spot that we can add in the score.
And it's going to be relatively easy to add this in because we already have that structure in place.
So if we do score and we can just call this a class of S. So it doesn't actually matter what class we
give it as we're not referencing it via the classes, we're getting its variable value by inter text
that's being contained within EA.
So let's create a global object four score and set that to zero.
And then every time we click on it, we're going to update the score.
So going down to where we had the click, we're going to take score incremented by one and then output
that content into the visible area, into that visible element.
You're going to slow this down a little bit because it's going to be kind of hard for me to catch this
one.
So I want to be able to test it properly.
So let's slow this down quite a bit.
And you can see that now as I click on it, my scores are increasing.
So I do have the ability to track the number of clicks that are being done on it.
So great.
And we can speed that back up again.
And you could adjust the speed as needed to make it more interesting.
You could also have more randomness within the speed, of course.
So it's all up to you however you want to create this type of interaction.
And of course, the faster the speed, the harder it is for the user to kind of catch it and click on
it, even though it's still possible.
So it makes the game more interesting.
So it looks like we've got a completed game.
And at this point, usually it's a good idea to kind of play through it and make sure that it's met
all of your objectives that you set out to in order to create it.
And once it does, then you're ready to launch your game.
And coming up next, we'll run through our source code and do a quick code review of all of the code
that we've generated and created in the earlier lessons.