This lesson is about setting up the actual gameplay, so we do have start game, we plus the start button
now it should disappear.
We need to set up a few variables for the player, create a global object.
So for now, I'm going to set one value in here and this is going to be game over to make sure that
the game is actually over is true.
And that will give us the ability to start the game, prevent any default game starts that might happen.
So that's the first condition that we're using is player game over.
And and if it is set to true that we can run through the start game functionality and the first thing
that we want to do within the game over is we're going to set game over to be false so that the game
is in play and we can't press the start button over and over again, hide the game over screen.
So taking that game over screen style and the property that we're going to play is displayed properly.
So setting that to display none.
What happens is the start button heights.
We start our gameplay also update some of the score values.
So this is the ideal spot to set the player score and we want to set player score to be zero also where
the number of lives that we want to set up for the player.
So this is where we can create that.
So in this case, let's set the lives to three.
And we also want to update the ball property so that one is one that's hidden.
So we want to take that display property of the ball and set it to block so that we can see the ball
because that one is going to be moving and it's a crucial part of the game.
So refresh hit the start button and we see we've got the ball and of course, we need to make the ball
animations, but we do have our paddle moving.
So that's a good thing.
And we can continue to build out what we need for the start.
So we also need to build our bricks.
So set up the bricks.
So we're going to have a function to set up bricks, bricks that we need to break.
And also we're going to update the score so we'll have a score later function and we can create this
one now because now we've got a value for score and lives so we can create a function that can update
and we can call it score updater.
So it's going to use the document query selector selecting the element with the class of score and we're
going to update the text content to be equal to the player score.
So this is where the actual score is going to be kept and we're just using this as a way to update it.
And we can also update the number of lives here as well.
There's a lot of times you're going to be updating these together anyway, so we'll have them within
that one function.
So now when we start the game, we've got a score of zero lives of three.
So that's one of the other things that we needed within the start and then set up bricks we're going
to take care of in the upcoming lesson.
I'll show you how to do that.
And within the start game, this is where you need to just consider what you need in order to start
the gameplay.
So the next part of this is that we've set up the player variables that these are going to be changing
through the game.
So player game over.
So if it's in game play and the score, the lives, we've also hidden the element as well as showing
the ones that we want within the game area.
And we've updated the visible score so we can continuously call back to score updated every time we
have a change within the score and the lives.
We've got that request animation frame, which we saw last time.
So that's in here as well.
And we're all ready to move on to the function where we're setting up the bricks.
And that's coming up next.
So go ahead and add in the start game functionality.
And I'm also going to go to this console message because we don't need that one anymore.