We've got our game playing and we don't have an end to it, so that's what we wanted to add in.
And the objective is that if you miss three with a positive score, then your lives are going to decrease
and eventually go down to zero and then the game is over.
So whatever you've scored without scoring any of the negative ones, that's going to be your score.
You could also do this on counting the different times you saw the different pop ups and having a limited
number of those like 50 or 100.
So there's a few different ways to make this game more interesting with an end to it, of course.
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
pop.
So this is where we can look to see if the player missed it and within that time out.
So make this a little bit bigger and within our timeout.
So this, again, is that time out.
So the player hasn't clicked the loss, then?
That's fine.
But if they haven't clicked a positive value one, then that's where they're going to lose one of the
items or one of the lights.
So adding that in and this is just going to be another condition here where we're going to check to
see if whatever the value of Newport was.
Remember, we're grabbing and setting that value in here so that we always can access it and use it.
So if the new pop value is greater than zero, so that's anything that's a negative.
So that's not going to be counted.
So that's fine.
And we see that that means that the player should lose some of the items.
So the items were actually lives and we're just going to decrease it by one.
And we should also update our score.
So use our update score function.
And next, let's check to see if the player items is less than or equal to zero.
So that means the game's over and then we can run our game over function.
So let's set up a function for that to keep that separated because this one is getting fairly long.
So setting up our game over, function game over and this is what we want to happen when the game is
over.
So we've got our plate area and we've got our inplay.
We've got our game.
And it's actually player we had where we've got our game over, so that's the object that we've got
that.
So that's the game over value.
So setting that to.
True, so our game is now over, so that will stop it from creating New Pops.
We need to update the play area and this is where we're toggling that class list and we're adding a
class of visible.
And we're flipping between the different pages, so this is going to give the player the ability to
start the game again and the other one, the game board.
So we've got our game.
We're going to remove visible.
So it's going to make it in.
And then also documents.
And query selector, and we want to update the text here.
So going all the way up to our style.
So we've got our.
A new game, so instead of a new game, because we've already played the game, we want to update our
text in the game over.
So that one was new game class and inner text or inner turmoil with the inner text, and we'll just
try again.
And that's going to end our game.
So whatever the score is, that's going to be the ending point of the score.
So if you miss.
Too many of the good ones, then your game is over.
So let's try that out.
So if you have missed one.
I've missed you, I've missed.
Three, and that was the last one, so our game is now officially over.
So go ahead and add that in your project.
Coming up next, we're going to clean this up.
As you can see, we're covering the SCHAUS.
We do want to be able to see that score.
So we need to apply some success and just do some final tweaks and adjustments within the gameplay.
So that's coming up in the next lesson.