Hey, and welcome back in this lesson, we're going to be restricting the power position of our ship
that we're moving so we don't want it to be able to move off screen and when it hit start that we get
the activation of being able to move it.
And you can see that it moves outside of the container area.
So we want to stop the movement for off of the container area and we want to restrict it within those
boundaries so we can do that within the condition where we're checking to see if left is pressed and
also checking to see if the value of the left position so that the temp position is greater than zero.
And if it is, then we're OK to subtract.
So let's try that.
And now whenever we move, so we're getting a value of greater than zero, but this is the main offset
value.
So we want to make sure that it's related to the container.
So checking again, that container dim and we do have a left position for that container.
So now let's try that.
And you can see when hits start game that now we're restricted to the left position and we can also
do the same thing for right where we're checking to see if the position.
So temp position is less than a container right position.
So it's in that container.
We had a number of options.
We could also do with and I'll show you what happened here is that we're actually moving off of the
screen, and that's because we're restricted to the right position.
But the right position is here and the right the left position of this object is over here.
So we need to add to the position the width of that current ship.
So adding that in and the way that we can do that.
So just as we did the offset left, we can do offset and there's an option here for offset width.
So now if we calculate that, that's going to give us the right side of our ship.
So moving that in.
Now you can see that we're restricted within the container boundaries and we can't go outside.
So go ahead and add those conditions into your project.
So this gives you the ability to restrict where the player can move with their with their ship.