Hey, now the fun part, and this is always a great idea to kind of play through the game, make sure
that you've got all the functionality and it's working the way that you're expecting it to work.
So make sure that everything is working, run through it a few times, make some tweaks and adjustments
to the numbers, because this should be fully dynamic so that you can adjust how many lives you have,
what the starting score is, starting positions, the speed of the ball and so on.
So you can make all of these adjustments within the settings in order to properly test your gameplay.
So the one thing that we did notice in the last lesson is that the paddle can still run off the screen.
So this is a relatively simple fix.
So let's do that right now.
And that's before we subtract.
We want to make sure that the paddle and the current offset so both the paddle and P current is greater
than zero.
So that should take care of it moving off the left hand side.
So let's see how that works.
So now we can't move off of the left hand side.
We can still move off the right hand side.
And this is a little bit trickier because once again, we do have to make some calculations here because
the paddle right side and the position, the dimension of the width, we need to make a subtraction
off that.
So show you what I mean.
So when we take our current position, remember, this is the offset left.
So this is going to be that edge here on the left hand side of the paddle.
And we want to take that and make sure that that is less than before.
We increment it by five.
We want to make sure that that is less than the container dim wit that will make sure that the left
edge is can't go past here, but our paddle is still going to go off screen.
So one more adjustment and that's going to be subtracting the paddle offset width and that will give
us the width of the paddle.
And we actually know that, but we want to make it a little bit more dynamic.
So in this case, we can make it more dynamic when we do the subtraction and make sure that we are making
the proper calculation.
And I need one more rounded bracket there.
I believe take our container with subtract the width of the paddle.
So that should bring us to the edge point here.
Subtract in the width of the paddle to here and we're checking to see if the current is past that point.
So try that and make sure that we can't go past the edges.
And I am pressing that Iraqi I'm not able to move past the edges.
So everything seems to be working properly and again, play through the game, make sure you do have
the functionality that you are looking for and any little minor tweaks or adjustments.
You can adjust some of the values within the calculations to make sure that it is functioning properly
as well as where you're setting up the bricks.
You can adjust how many bricks you're setting up and just notice that we're not actually checking to
see if there's no bricks on the screen to check to see if the game is over.
So that was another quick tweak that we need to make sure that we have a way to reset the bricks where
we are selecting all of the bricks.
This is the ideal spot to check to see if the node list has a zero value so you can write in a condition
checking to see if Brix length is equal to zero.
So that means there's no bricks within the no.
If we don't return anything in the node list from querying all the elements with brick, that means
there's none available and actually the game should be over and we want to run our stopper function.
So that will stop the ball from moving.
And then we want to set up another set of bricks or we should set a value for the number of bricks that
we're creating.
Just check double checking to see within the setup if we've got that dynamically.
And if not, then it should be dynamically generated.
So we do have a set up of bricks, so let's create a value for it within the player.
And we just call this NUM so this can be thirty.
And then now whenever we want to set up the bricks, we can always have the setup of the bricks or we
can increment that every time.
So adding even more bricks or decrease in the number of bricks.
So again, making it dynamic whenever the game is ending, we can update that.
And whenever we're running out of bricks, we can update that as well.
So we'll set up a new set of bricks.
We're going to stop the ball from moving and we'll see how this works out.
And I think initially what we'll probably do so because, of course, we are just testing.
I'm only going to set up two bricks so that when we start the game, we get rid of both bricks and we
should be able to relaunch and we see the new bricks are generated.
So that's working.
And this last one was a little bit tricky.
So just make sure that you can constantly go through it and it produces new bricks and we see that the
score is still the same, the lives are still the same.
So none of that has been affected and nor should it have been so great.
Next.
Coming up, we're going to do a quick run through the code and a review of the code that we've writing
in the earlier lessons.