So I know the last lesson was fairly intense, but the good news is that now it's all smooth sailing.
We've got all of the functionality that we need and now it's just a matter of making some minor tweaks,
adjustments within our gameplay.
We see that whenever we're dropping our bombs, if they're hitting our target, we're getting this crash
value.
And we know that once we get that, then that's a score we want to be able to score to the player.
So let's update the player score and add in a value of 2000.
Also, we want to remove out that base and recreate it somewhere else because now that one's been destroyed.
So taking our player base, we need to move up to its parent element.
So whatever the parent element is, and just as we did over here to move out the bomb, we need to navigate
up to the parent element and then do the remove child and select our player base as the child.
So that will remove it from our visual area.
And we also need to take our bomb and remove that one as well.
And then lastly, we need to make another enemy because we need to keep the game going.
And we already have that function built.
So taking that function.
So instead of crash, we're just going to generate a brand new enemy.
There's a few other things that we still probably need to take care of.
So let's try the game out and we're going to see what else we need to tweak and adjust.
So now the way that it should play, if I hit the target that we get a brand new one in our score increases.
So so far that is working as expected.
We can see that I am hitting the target and it is updating that value.
The number six.
So the bombs are outputting the value of how many are active.
So maybe we don't want that to happen and we want to have a different value.
So we could really easily add that in.
We could count all of the bombs that have been added so we could do something like player bomb score
and equal that.
So just increment that and maybe that's the value that we can output.
So every time the player has another drops, another bomb, that's just going to increase that bomb
score.
And that means that we need to set another value in here at zero.
So let's try that out.
So now we get one, two, three, four, and it's not counting how many active bombs we currently have
in process.
So the other thing, too, is that we wanted to make sure that when we make a bomb that this value of
player active bomb is going to be less than what our bomb score is or total bombs is getting confused.
Let me make that a little bit bigger.
So we want to make sure that we're not able to we're only able to create them if this statement is true.
So that means that we can only have two at a time on the screen, so let's try that now so we only have
two out of time on the screen.
And whenever we have those ones drop off, we can create more.
So that's a way to adjust the number that are currently on the screen.
If we want to have the ability to have more, we can implement that as well.
So now we can have up to six on the screen at one time.
So we also might want to introduce the number of levels of bombs.
So let's do another one and we'll do level will have ten bombs or every time we make a new enemy that
we're going to decrease.
This value is less than zero.
Then that means that we end the game.
So we're not going to make an enemy that we just simply go out and we end game.
So I have a function for that.
And else we can continue to make more bases and actually bring this level down to just one and we'll
just add that function.
And so adding the function to end the game as we do need to have an end for the gameplay, of course.
So adding in the console message and game over and we'll create will show the start button once again
once it's over.
So this one's a little hard to hit.
So let's so I just skip over part of that in order to hit the actual target.
But see, we've got the game over.
So that means that we should stop the gameplay and we can set that to false.
So that will stop our gameplay because we've got our inplay is true.
So I set it to false and let's also set this to zero.
So we left at one of the targets.
So now we've got game over at stops and we can output a message back to the player so we can bring back
the start screen.
So the one that we added the class of height, so we'll remove hide from that element.
So now if we hit it, we should get our start screen again.
So we got our start screen again.
We're able to start it again.
Let's see what happens.
So we didn't quite clear out all of our content.
We made another plane.
So that's another thing that we need to take care of.
The next time we start out, we need to clear our game area.
So let's take our game area and update the in HTML.
And just make it blank, so sometimes you do need to play through a few times just to make sure that
you've got all of the functionality that you want to make sure the inner turmoil is cleared and then
we make the enemy.
So you need to reverse the order of those.
So let's move this value above it.
So we're setting a value of player level so we can actually create at least one of the enemy bases.
So we've got game over, we create another base game over, we create another base and we're able to
continue our play.
So now we can set of the player level.
We can give her this console message that says game over and we can customize all of the rest of the
content as needed.
Let's make this bigger and we'll do another quick restart of it just to make sure that everything is
working as needed.
So now when we blow up and we kill off 10 of the enemy bases, that's when our game is over.
And if you ever do need to get some of the values, you can, you can see it within the global object
of player.
So we've got our score value here.
We've got our base.
We've got our plane here, level three.
That's how many enemies that how many bases we still have left.
We have a bomb score of six active bombs of six.
So there is a problem there that are active.
Bombs aren't decreasing.
So that's another bug that we need to still update and fix.
And the problem here is that we're not decreasing the number of active bombs, but we are removing them
from the play area.
So we need to fix that as well.
So we're moving them and we're taking away the active bomb here, but we're not taking it away over
here.
And that's where we're getting that inconsistent number.
So let's try that again one more time.
So now, whenever we hit the enemy base, we've got to make sure that are active bombs are adding up
as well.
So if we don't have any active bombs on the screen, it should always be back to zero.
This is how many we've dropped so far.
And this is we also have the total bomb.
So that's our max that we can drop at any one time.
And as you can see, once I start dropping some more, these values are going to be updating.
If output player again, you're going to see that those values are changing.
So go ahead and play through the game a few times, make sure that it is working as needed.
And coming up next, we'll do a quick code review, an overview of the code that we've been working
through.