Hello and welcome to another episode in the Godot basics tutorial series. In this episode we will be taking a look at Boundary games boundary games also referred to as a bounded game is a game where space is finite and a character is bounded to the height and width of your game screen. The best way to think about this is through some of the classical games we know. One such thing would be space invaders in space invaders.
We had a army of aliens moving downwards. The most important thing to note however is that your main character which was the hero ship was able to move left and right along the maximum width of your game screen in this case the arcade game screen. Now the Space Invaders game is considered a bounding game. The reason for that is because our player ship is free to move left and right. However it is not allowed to move past the left side or right side of the arcade games screen.
And so if we broke down the game it would look something like this. So in this case we have our player object a blue pikachu. We do have the ability to move left and move right. In this case we're moving right and we'll keep moving right. However in modern games we can actually go past the edge of the game with. So in this case our offset is equal to the value of the maximum game width of our screen and any bounded game. We do not want this to happen. We would like to keep our entire game image bounded to our game window and to do this it's fairly straightforward.
In this case we are allowed to move right until the value of our offset plus half of our image width is less than the game width of our window and you can do the same thing for the y axis as well. So we are free to move down in our game window as long as the offset plus half of our image height is less than the maximum height of our game window. Keep in mind that X Max is the game window width and Y Max is the.
Game window height. Keep in mind that we are considering Godot where a positive y value means we are moving further down in our screen. Now let's look at the homework assignment. So for this episode's homework assignment you're going to create a bounded game object and so you need to do four things. The first is that our game object needs to be controlled through player inputs whether you use up down left right arrow keys or w a SD your game object needs to move in four different directions which leads to the second homework objective which is that your game object needs to move up down left and right.
The third objective is that you need to create the code to bound your game object within the game screen that means your game object is not allowed to go beyond the height and width of your game screen. In that case what that means is that when you move left right up and down I should be able to see the entire image and your game object cannot go pass your game screens height and width. Lastly on every game start you need to center your game object to the middle of the screen.
Now that seems like a lot however believe it or not. We did half of the homework assignment. If you've been doing your homework up until now so we already have code that moves our game object up down left and right and we also have code that positions or game objects at the center. That means you've essentially done half of the homework assignment and so all you really need to focus on is 1 tying your game objects movement through player input and then making sure that player inputs are inactive when you're game object is just barely close to the edge of your screen.
So good luck with that. Well thank you so much for joining me in this episode. Thank you for clicking the Like button. Thank you for clicking the Subscribe button. If you have any questions or comments please feel free to leave them in the comments section down below.
I look forward to seeing you in the next episode. Have an amazing day