So, congratulations, after learning all the basic and essential concepts of our pygame series, you are finally here to get the Overview of our First Game Project
In this article, we will get to know about what game we are gonna make in the next article. But before that, in this article, we will try to understand and analyze the game so that it becomes easy when we start coding.
Overview of our First Game Project
Now let’s try to analyse the game.
When we run the game, there is background music that plays in the loop and we already know how to add background music in a game using pygame and python. If you don’t know then we recommend you to read our previous article about adding sound in your game window using python and pygame. Here is the link: Adding Sounds using pygame and python.
And we also see a solid dark grey background color and a title, that is “Protect the CEO”. And we also know how to add background color in our game window. If you don’t know then you can consider the following link: Customizing game window using Pygame and Python.
And at the top left corner of the window, we see a score board, that is a text.
And at the bottom, there is an image of a man, who is still in his position. And there is also an image of a woman… The concept of this game is to protect the Guy, who is the CEO of that Gold Digger Girl. And to do that, there is a block that protects the guy…
Now, let’s talk about the mechanics of the game.
As we can see, the lady is constantly moving, and when she collides with any wall of the game. By wall I mean the boundaries of the game, so, as soon as she collides with the wall, she starts moving in the opposite direction.
By this movement, we can clearly see that by colliding with the wall there is no change in her movement in the Y direction. So, to change the direction of the girl, we need the change the movement in opposite direction and we do that by simply changing the value of X to negative.
Let’s take an example:
If X increases by 1, then our equation must be looking like X+=1, and to convert it to negative we will simply just multiply it by -1.
If X = 2, then -1 * X = -2, and now if X = -2, then also we can change it’s direction opposite of what it is at the moment by multiplying it by -1, X * -1 = +2.
The rule is exactly the same what we studied in middle school.
Positive * Positive = Positive
Positive * Negative = Negative
Negative * Negative = Positive
And now, let’s talk about what happens when the girl touches the protecting block.
When the girl touches the block or the upper wall, and as soon as she does that, her movement is changed in the exact opposite direction, that is in the Y direction. And to do that, we will do the same that we did to change the X value, i.e. to multiply it by -1. And it will change the direction of the movement of the girl.
So, this was all about the movement of the girl, now let’s talk about how we will detect that the girl has touched the block.
It’s simple and easy. Let’s say, I have an image of a block the extends to the left-right boundaries. If my image was 100px, then we know that the size of the block horizontally is equal to 100px. If we take one side of the block as the starting point, then we know that the other end is exactly 100px. And in pygame, the coordinate of an image is calculated from its top left corner, and if we observe it, we see that the distance from the top left corner to the top right corner is the distance that we are talking about.
Now that we know, what’s the size of the block we can now simply put an if statement to check that is the coordinate of the girl is greater than equal to the block current coordinate in the X direction and less than equal to the (current coordinate in X direction + Horizontal size of the block), then change the value of Y for the girl to negative of its current value.
And if the girl goes below the block, then the game is over. And we can detect it by finding the bottom-most coordinate of the block in the Y direction and if the girl’s coordinate is more than that, then display the game is over and pause the game.
For the Scoreboard, we increase the score by one every time the block collides with the girl. And we know how to detect that collision so that’s also now easy enough to do.
For the sound effect, there is a laser sound that plays every time the block collides with the girl. And again… you know how to make that work.
If you are new here then we recommend you to, see our previous articles.
So that is it for this article, we will now see you on our next article where we will build our first complete game. Until then enjoy learning.
- Creating a Pong Game using Python TurtleIntroduction Today, we are going to create a Pong Game using Python Turtle. Pong is a well-known computer game that is similar to table tennis. The two players in this game control the two paddles on either side of the game window. To hit the moving ball, they move the paddles up and down. A…
- Balloon Shooter Game using Python PyGameWe all know the importance of the pygame library in terms of game development. We know that Pygame is a collection of Python modules for making video games. It is a collection of computer graphics and sound libraries for the Python programming language. Pygame is well suited to the development of client-side applications that may…
- Complete PyGame Tutorial and ProjectsWithout a doubt, we can say that Python is a multi-purpose language. Ranging from basic programming to its application in Data Science, from Machine Learning to Artificial Intelligence, and also in Developing Games. In simple words, it’s the language that is incomparable.With knowing the advantages of Python, today, in this article of Complete PyGame Tutorial…
- Flappy Bird In Python Pygame with source codeOVERVIEW OF THE PROJECT Hi there, welcome to the copyassignment hope you all are doing wonderful. Today, we are here to make a very interesting game Flappy Bird In Python Pygame. Hope you are familiar with this entertaining and very fascinating game. We would see how we can code the game Flappy bird from Scratch….
- Complete Racing Game In Python Using PyGameSo far we have learned a lot but there is not anything to end our game and now we are now going to see part 2 of our project. So, in this section, we will Create a Complete Racing Game In Python Using PyGame. So that we can use it to quit our game. Detecting…
- Complete Game In PyGame and PythonNow, it’s time to create our fully featured Complete Game In PyGame and Python with all the knowledge that we have gained from this series of articles. If you have seen the overview of our game, then maybe you have already made it. If yes then congrats, or you can follow along. To create this…
- Python Complete Setup for PygameNow, it’s time to install the tools that we will use to write programs. So, we will be learning Python Complete Setup for Pygame in this article. Let’s start. 1. Installing Python first. First, we need to go to the official site of python: https://www.python.org/ Now we need to go to the downloads page of…
- Overview of our First Game ProjectSo, congratulations, after learning all the basic and essential concepts of our pygame series, you are finally here to get the Overview of our First Game Project In this article, we will get to know about what game we are gonna make in the next article. But before that, in this article, we will try…
- Car Race Game in PyGame Python: From ScratchCheck the video below to know about our Car Race Game in PyGame and Python we are going to make. If you don’t know Pygame, then you should not worry, we will guide you from scratch. You just need some basic Python skills, other than Python, we will guide you with everything. Introduction to Car…
- Add Background Music and text to PyGameSo, far we have learned how to add images and mechanics to our game. In this article, we will be learning to add Background Music and text to PyGame. So, do the following changes in the final code that we got in our previous article after adding movement. Adding text to PyGame window: Now, adding…