This lesson, we're going to be introducing some fixes for the game and as we saw last time, we can
keep producing multiple planes and we actually don't want that.
We don't want the ability to produce more and more planes every time we hit the start button.
So we need to hide this start button and this game message area until we actually need to make use of
it.
So let's introduce another class and we can just call that right and using display and setting it to
none.
And what we're going to do, we're going to add this class to that element when we hit start.
So that's going to hide that message area until we need to make use of it.
So we've got our A game message object that we created in the earlier lessons taking the class list
method.
And we've got one called ADD and that's the one that we need in order to add a class to that element.
I'm also going to be updating some of the way the game message looks because it does look a little bit
plain, just being words.
So I wanted to update some of the values there as well as do a position absolute for it.
So we have an option to move it around a bit if we need to.
And also, we're going to set it off of the bottom or set it off off of the top as a percentage.
So top 10 percent, we can do a left 20 percent.
And that means that are which should be 60 percent to center our message.
So that's 60 plus 20 or so.
Right.
20 would be one hundred percent as full.
Also, text align center is always a good way to go, setting up the background color to distinguish
it.
I said it as Alice Blue for now, the font size.
So the font is bigger, but we do to em and save that.
So let's try that out and we'll see that we get this press here to start game and when we press it,
it disappears so we can't actually press it again.
And that's exactly what we want because we only want that one plane object.
So let's do one more condition just to double check and make sure that we're not interfering with already
existing gameplay.
So doing player in play.
And this is the only time while we're in play, if it's not in play, then that's when we create the
new player.
So let's try that one more time.
So now I can keep pressing and I'm not producing a second plane.
So there's a few other things that we need to still take care of.
A few other bugs.
Notice that the plane can go off screen so it's not good.
So we need to create a bounding area for the plane.
And that's going to be relatively easy to do because we're already checking to see if our arrow keys
are up.
And before we actually allow this action to take place, we can see the value of player Y.
So taking arrow key up and the value of player Y.
And make sure that it's greater than zero, and if it is, that we could subtract off of it and correspondingly
as well, let's take this one and make sure that player Y is less then and we're going to set up two
hundred because I don't want the plane going all the way down.
So we're creating a boundary area for the plane to interact and moving it left.
So we want to make sure that Player X is greater than zero.
And this one here, we want to make sure that Player X is less than the offset of the game.
So Player X is less than and this is where we're going to use some dynamic values.
And being dynamic is always better because in case you change the area, the game area size, we can
use that value that we saw earlier where we've got the offset with minus let's subtract 50 to account
for the plane size.
So we're going to make sure that the plane essentially can't run off the side of the screen.
And one more bracket there.
So let's refresh try that out.
So now whenever we move over to the right, you see my right arrow in my left arrow is true, but I
can't move any more to the right.
I can't move any more to the top and I can't move any more to the bottom.
And let's just make sure that our boundary box is working so it can't move any more over to the right
hand side.
So that's great.
Now we've added in the boundaries for our plane to be able to move around and navigate with them.
So go ahead and add this into your project as well.
And coming up next, we're going to introduce some more of the gameplay that we need to take care of,
including moving the plane automatically because we want the plane always automatically to be going
forward, as well as trying to introduce some scoring.
So that's still to come in the next lesson's.