Complete Game In PyGame and Python

Complete Game In PyGame and Python

Now, 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 game you need to have the required media files from the game.

Here is the link from which you can download all the necessary media files in this tutorial.

Download necessary Media Files for our Complete Game Project

Complete Game In PyGame and Python

1. Importing and initializing Pygame

Let’s import pygame, by using the following command.

import pygame

And now initialize it using,

pygame.init()
assignment advertisement

2. Creating the basic game window

After importing and initializing pygame, let’s create the game window/screen. To do that, let’s write the following code.

# Creating the screen
screen = pygame.display.set_mode((800,600))


Now that we have created the screen, we need it running until the close key is pressed. So, we will write the following code to make that work.

# Creating Boolean variable to keep the game running
isRunning = True
# Creating the game loop
while (isRunning):
    # Checking all the events that are happening on our screen
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            isRunning = False

Now that we have created a blank game window. Now we will set a color for it and then update the screen. To do that we will write the following code inside our game loop.

# For colour, we will write
screen.fill((69,68,65)) # It's a grayish colour
# And to Update, we will write the following code in the very end of the game loop.
pygame.display.update()

After adding all of the above code, our whole code should be looking like this:

import pygame

pygame.init()

# Creating the screen
screen = pygame.display.set_mode((800,600))

# Creating Boolean variable to keep the game running
isRunning = True
# Creating the game loop
while (isRunning):
    # For colour, we will write
    screen.fill((69,68,65)) # It's a grayish colour
    # Checking all the events that are happening on our screen
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            isRunning = False
    
    # And to Update, we will write the following code in the very end of the game loop.
    pygame.display.update()

3. Let’s set the title and icon for our game window.

# To add title and icon to our game window we will write the following code before the game loop.

#Title
pygame.display.set_caption('Protect the CEO') # We will set the name of our game, that is 'Protect the CEO'.

#Icon
icon = pygame.image.load('man.png') # Here we are loading the man image from our resource.
pygame.display.set_icon(icon) # Setting the icon on the game window.

4. Now, it’s time to add the game characters and the protecting block.

First of all, let’s add our in-danger CEO. And his image is the same as our icon image, that is ‘man.png’. And we want his image at the bottom in the center of our Complete Game In PyGame and Python.

First we will load our image, and for that, we will write the following code outside the game loop:

# Creating CEO
ceo = pygame.image.load('man.png')

Now, we will blit the CEO’s image inside our game window. And to do that, we will write the following code inside our game loop.

# We use screen.blit() to place our image inside our game window
screen.blit(ceo, (375,540)) # After adjusting, I found this coordinate to set our CEO in the very Bottom-Center.


Now, let’s run it. Notice the position of our CEO.

Now, let’s add our protecting block inside our game, to protect our CEO.

The name of our protecting block image is ‘block.png’. And as we want our block to change its position horizontally, so we will create a variable containing the X coordinate of the block. And when the arrow keys are press (Left and Right), we will change the value of the X coordinate respectively and that will change the position of our block.

And to detect the arrow keypress, we will use events. So let’s write the code.

# Loading the block image
block = pygame.image.load("block.png")
# Variable containing the X and Y value of the block
blockX = 300 # After adjusting the image accordingly in the center
blockY = 375 # Above the CEO's image
# Variable containing the change of the value that happend in blockX
changeX = 0

Now, let’s code inside our loop, to change the position of block accordingly.

# Inside the for-loop, that loops over all the events
if event.type == pygame.KEYDOWN: #This runs, when a key is pressed
            if event.key == pygame.K_LEFT: #This checks if the keypress was of the left arrow key
                changeX-= 3 # To change the positon in left direction
            if event.key == pygame.K_RIGHT: #This checks if the keypress was of the right arrow key
                changeX+= 3 # To change the positon in left direction
        
if event.type == pygame.KEYUP: #This runs when a key is released after press
            changeX = 0
# This will run after the for-loop
# The following statement is to check if the block is touching the boundaries, if yes then stop immediately because we don't want our block to move outside the game screen. 
if blockX+changeX>=546 or blockX+changeX<0:
        # If it touches the boundaries then change the changeX to 0. This will stop the change to happen to the block.
        changeX = 0
else:
        blockX += changeX


# Now let's do, screen.blit()
screen.blit(block, (blockX, blockY))

After writing all this, your full code right now should be looking like this:

import pygame

pygame.init()

# Creating the screen
screen = pygame.display.set_mode((800,600))m 

# Creating Boolean variable to keep the game running
isRunning = True


# To add title and icon to our game window we will write the following code before the game loop.

#Title
pygame.display.set_caption('Protect the CEO')

#Icon
icon = pygame.image.load('man.png') # Here we are loading the man image from our resource.
pygame.display.set_icon(icon) # Setting the icon on the game window.


# Creating CEO
ceo = pygame.image.load('man.png')

# Loading the block image
block = pygame.image.load("block.png")
# Variable containing the X and Y value of the block
blockX = 300 # After adjusting the image accordingly in the center
blockY = 375 # Above the CEO's image
# Variable containing the change of the value that happend in blockX
changeX = 0

# Creating the game loop
while (isRunning):
    # For colour, we will write
    screen.fill((69,68,65)) # It's a grayish colour
    # Checking all the events that are happening on our screen
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            isRunning = False
        
        # Inside the for-loop, that loops over all the events
        if event.type == pygame.KEYDOWN: #This runs, when a key is pressed
            if event.key == pygame.K_LEFT: #This checks if the keypress was of the left arrow key
                changeX-= 3 # To change the positon in left direction
            if event.key == pygame.K_RIGHT: #This checks if the keypress was of the right arrow key
                changeX+= 3 # To change the positon in left direction
        
        if event.type == pygame.KEYUP: #This runs when a key is released after press
            changeX = 0
    

    # This will run after the for-loop
    # The following statement is to check if the block is touching the boundaries, if yes then stop immediately because we don't want our block to move outside the game screen. 
    if blockX+changeX>=546 or blockX+changeX<0:
        # If it touches the boundaries then change the changeX to 0. This will stop the change to happen to the block.
        changeX = 0
    else:
        blockX += changeX


    # Now let's do, screen.blit()
    screen.blit(block, (blockX, blockY))
    # We use screen.blit() to place our image inside our game window
    screen.blit(ceo, (375,540)) # After adjusting, I found this coordinate to set our CEO in the very Bottom-Center.
    # And to Update, we will write the following code in the very end of the game loop.
    pygame.display.update()

5. Now, let’s add the enemy girl

In the overview of the game article, we saw the movement of the girl. So, let’s code her accordingly.

First let’s create the girl by loading her image.

# let's import random
import random
# Loading the image of the girl.
girlOne = pygame.image.load('girl (1).png')
# For Random start position. 
girlOneX = random.randint(0,770)
girlOneY = 100
Xchange = 2
Ychange = 2

Now, let’s work on the movement and collision detection of the girl. So, let’s code it.

# All of this code is written inside the game loop after the for-loop of events

# This will change the position of the girl, everytime the loop executes
girlOneX+=Xchange
girlOneY+=Ychange
# This will check if the girl is touching any boundaries except the bottom one.
if(girlOneX<0):
    Xchange= 2
elif girlOneX>750: # After adjusting the maximum X value of girl in horizontal direction
    Xchange = -2 # This changes the movement of girl in opposite direction
elif girlOneY<0:
    Ychange *=-1 # This changes the movement of girl in opposite direction

if girlOneY>=480: #This checks if the girl has reached around the CEO
    # Right now, for reference. We will print the Game Over
    print("Game Over")
elif girlOneX>(blockX+changeX) and girlOneX<(blockX+changeX+254) and girlOneY>=425: #To check if the girl has touched the block
    
    Ychange*=-1
# Now let's do, screen.blit()
screen.blit(girlOne,(girlOneX,girlOneY))

Now, let’s try to run it. Notice the perfect movement of the girl and the block.

But we want a scoreboard and a Game over the window also to make this game more User Friendly.



6. Let’s create a scoreboard and game over the window

To display the score, we will create a function before the game loop in our Complete Game In PyGame and Python.

# Adding Score
score = 0 # Variable that contains score
# Creating the font
font = pygame.font.Font('freesansbold.ttf',24)
def displayScore(score):
    Creating score image by rendering the font
    scoreImage = font.render(str(score), True, (255,255,255))
    # Displaying it on the top left corner of our game window
    screen.blit(scoreImage,(10,10))

Creating the game over text.

def game_over():
    gfont = pygame.font.Font('freesansbold.ttf',45)
    game = gfont.render("Game Over!", True, (255,255,255))
    screen.blit(game, (275,275))

Now, let’s use these functions in our game loop.

We want our score to increase every time the girl touches the block. So we will write the following code inside the if statement that checks if the girl has touched the block or not.

# inside the following if statement
if girlOneY>=480:
     gameOver=True
     score+=0
elif girlOneX>(blockX+changeX) and girlOneX<(blockX+changeX+254) and girlOneY>=425:
     Ychange*=-1
     # Increasing the score
     score+=1

Now, let’s display the score, every time the loop runs.

So, after the loops and if statements, we will write our code to display the score.

displayScore(score)

Now, let’s create the game over window.

And for the game over the window, we want that all the things that are on my screen (except the score) should disappear. And to do that, we will simply create a boolean variable that will store if the game is over or not. And in the if statement, where we had put a print statement, We will change it.

Instead of printing Game Over, We will set our Game Over Variable to be true and then we will put all of our screen.blit() (for images) inside an if statement. If the game is over then display the game over text and remove all the images, else keep these images on the screen. Now, let’s write the code.

# First we will create a game over variable
isGameOver = False
# The following code will be written inside the if statement that checks, if the girl has reached around the CEO.
if girlOneY>=480: #This checks if the girl has reached around the CEO
        # Right now, for reference. We will print the Game Over
        # print("Game Over")
        # WE HAVE COMMENTED THE PRINT STATEMENT. AND NOW WE WILL SET THE isGameOver = True
        isGameOver = True
elif girlOneX>(blockX+changeX) and girlOneX<(blockX+changeX+254) and girlOneY>=425: #To check if the girl has touched the block
        Ychange*=-1
        # Increasing the score
        score+=1

Now, we will put the screen.blit statements of our images inside an if conditional statement that checks if the game is over or not, if true then run the game_over() function, else keep the screen.blit().

if (isGameOver):
        game_over()
    else:
        # Now let's do, screen.blit()
        screen.blit(girlOne,(girlOneX,girlOneY))
        screen.blit(block, (blockX, blockY))
        # We use screen.blit() to place our image inside our game window
        screen.blit(ceo, (375,540)) # After adjusting, I found this coordinate to set our CEO in the very Bottom-Center.

After writing all of this, you whole code should be looking like this:

import pygame
import random
pygame.init()

# Creating the screen
screen = pygame.display.set_mode((800,600))

# Creating Boolean variable to keep the game running
isRunning = True


# To add title and icon to our game window we will write the following code before the game loop.

#Title
pygame.display.set_caption('Protect the CEO')

#Icon
icon = pygame.image.load('man.png') # Here we are loading the man image from our resource.
pygame.display.set_icon(icon) # Setting the icon on the game window.


# Creating CEO
ceo = pygame.image.load('man.png')

# Loading the block image
block = pygame.image.load("block.png")
# Variable containing the X and Y value of the block
blockX = 300 # After adjusting the image accordingly in the center
blockY = 375 # Above the CEO's image
# Variable containing the change of the value that happend in blockX
changeX = 0


# Loading the image of the girl.
girlOne = pygame.image.load('girl (1).png')
# For Random start position. 
girlOneX = random.randint(0,770)
girlOneY = 100
Xchange = 2
Ychange = 2


# Adding Score
score = 0 # Variable that contains score
# Creating the font
font = pygame.font.Font('freesansbold.ttf',24)
def displayScore(score):
    # Creating score image by rendering the font
    scoreImage = font.render(str(score), True, (255,255,255))
    # Displaying it on the top left corner of our game window
    screen.blit(scoreImage,(10,10))

def game_over():
    gfont = pygame.font.Font('freesansbold.ttf',45)
    game = gfont.render("Game Over!", True, (255,255,255))
    screen.blit(game, (275,275))

# We will create a game over variable
isGameOver = False

# Creating the game loop
while (isRunning):
    # For colour, we will write
    screen.fill((69,68,65)) # It's a grayish colour
    # Checking all the events that are happening on our screen
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            isRunning = False
        
        # Inside the for-loop, that loops over all the events
        if event.type == pygame.KEYDOWN: #This runs, when a key is pressed
            if event.key == pygame.K_LEFT: #This checks if the keypress was of the left arrow key
                changeX-= 3 # To change the positon in left direction
            if event.key == pygame.K_RIGHT: #This checks if the keypress was of the right arrow key
                changeX+= 3 # To change the positon in left direction
        
        if event.type == pygame.KEYUP: #This runs when a key is released after press
            changeX = 0
    

    # This will run after the for-loop
    # The following statement is to check if the block is touching the boundaries, if yes then stop immediately because we don't want our block to move outside the game screen. 
    if blockX+changeX>=546 or blockX+changeX<0:
        # If it touches the boundaries then change the changeX to 0. This will stop the change to happen to the block.
        changeX = 0
    else:
        blockX += changeX

    # All of this code is written inside the game loop after the for-loop of events

    # This will change the position of the girl, everytime the loop executes
    girlOneX+=Xchange
    girlOneY+=Ychange
    # This will check if the girl is touching any boundaries except the bottom one.
    if(girlOneX<0):
        Xchange= 2
    elif girlOneX>750: # After adjusting the maximum X value of girl in horizontal direction
        Xchange = -2 # This changes the movement of girl in opposite direction
    elif girlOneY<0:
        Ychange *=-1 # This changes the movement of girl in opposite direction

    if girlOneY>=480: #This checks if the girl has reached around the CEO
        # Right now, for reference. We will print the Game Over
        # print("Game Over")
        isGameOver = True
    elif girlOneX>(blockX+changeX) and girlOneX<(blockX+changeX+254) and girlOneY>=425: #To check if the girl has touched the block
        Ychange*=-1
        # Increasing the score
        score+=1
    
    displayScore(score)
    if (isGameOver):
        game_over()
    else:
        # Now let's do, screen.blit()
        screen.blit(girlOne,(girlOneX,girlOneY))
        screen.blit(block, (blockX, blockY))
        # We use screen.blit() to place our image inside our game window
        screen.blit(ceo, (375,540)) # After adjusting, I found this coordinate to set our CEO in the very Bottom-Center.


    # And to Update, we will write the following code in the very end of the game loop.
    pygame.display.update()

Now, let’s run it.

And… Cool! It runs perfectly. But still, something is missing. Oh yeah… the background music and sound effect.



7. Creating the background music and sound effect.

This is the last thing that we need to do to create Complete Game In PyGame and Python.

For adding music, we will be requiring a module from pygame called mixer.

Let’s do it.

from pygame import mixer

Now, let’ create the background music. We will write the following code before the game loop.

#Background Sound
# Loading the background music.
background = mixer.music.load('background.wav') #The name of my music file is background.wav
mixer.music.play(-1) # We use -1 to tell the mixer to play this music on repeat. It's like a code for it.

Now, let’s try to run it.

And it works!

Now the only thing that is left, is the laser sound effect when the girl touches the block.

We will write the code, inside the if statement that checks the collision between the girl and the block.

# INSIDE THIS IF STATEMENT

if girlOneY>=480: #This checks if the girl has reached around the CEO
        # Right now, for reference. We will print the Game Over
        # print("Game Over")
        isGameOver = True
elif girlOneX>(blockX+changeX) and girlOneX<(blockX+changeX+254) and girlOneY>=425: #To check if the girl has touched the block
        Ychange*=-1
        # Increasing the score
        score+=1
        # Let's play the laser sound effect
        sound = mixer.Sound('laser.wav')
        sound.play()

And here we go! After writing this, your whole Complete Game In PyGame and Python code should look like this:

import pygame
import random
from pygame import mixer
pygame.init()

# Creating the screen
screen = pygame.display.set_mode((800,600))

# Creating Boolean variable to keep the game running
isRunning = True


# To add title and icon to our game window we will write the following code before the game loop.

#Title
pygame.display.set_caption('Protect the CEO')

#Icon
icon = pygame.image.load('man.png') # Here we are loading the man image from our resource.
pygame.display.set_icon(icon) # Setting the icon on the game window.


# Creating CEO
ceo = pygame.image.load('man.png')

# Loading the block image
block = pygame.image.load("block.png")
# Variable containing the X and Y value of the block
blockX = 300 # After adjusting the image accordingly in the center
blockY = 375 # Above the CEO's image
# Variable containing the change of the value that happend in blockX
changeX = 0


# Loading the image of the girl.
girlOne = pygame.image.load('girl (1).png')
# For Random start position. 
girlOneX = random.randint(0,10)
girlOneY = 100
Xchange = 0.5
Ychange = 0.5


# Adding Score
score = 0 # Variable that contains score
# Creating the font
font = pygame.font.Font('freesansbold.ttf',24)
def displayScore(score):
    # Creating score image by rendering the font
    scoreImage = font.render(str(score), True, (255,255,255))
    # Displaying it on the top left corner of our game window
    screen.blit(scoreImage,(10,10))

def game_over():
    gfont = pygame.font.Font('freesansbold.ttf',45)
    game = gfont.render("Game Over!", True, (255,255,255))
    screen.blit(game, (275,275))

# We will create a game over variable
isGameOver = False

#Background Sound
# Loading the background music.
background = mixer.music.load('background.wav') #The name of my music file is background.wav
mixer.music.play(-1) # We use -1 to tell the mixer to play this music on repeat. It's like a code for it.

# Creating the game loop
while (isRunning):
    # For colour, we will write
    screen.fill((69,68,65)) # It's a grayish colour
    # Checking all the events that are happening on our screen
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            isRunning = False
        
        # Inside the for-loop, that loops over all the events
        if event.type == pygame.KEYDOWN: #This runs, when a key is pressed
            if event.key == pygame.K_LEFT: #This checks if the keypress was of the left arrow key
                changeX-= 3 # To change the positon in left direction
            if event.key == pygame.K_RIGHT: #This checks if the keypress was of the right arrow key
                changeX+= 3 # To change the positon in left direction
        
        if event.type == pygame.KEYUP: #This runs when a key is released after press
            changeX = 0
    

    # This will run after the for-loop
    # The following statement is to check if the block is touching the boundaries, if yes then stop immediately because we don't want our block to move outside the game screen. 
    if blockX+changeX>=546 or blockX+changeX<0:
        # If it touches the boundaries then change the changeX to 0. This will stop the change to happen to the block.
        changeX = 0
    else:
        blockX += changeX

    # All of this code is written inside the game loop after the for-loop of events

    # This will change the position of the girl, everytime the loop executes
    girlOneX+=Xchange
    girlOneY+=Ychange
    # This will check if the girl is touching any boundaries except the bottom one.
    if(girlOneX<0):
        Xchange= 1
    elif girlOneX>750: # After adjusting the maximum X value of girl in horizontal direction
        Xchange = -1 # This changes the movement of girl in opposite direction
    elif girlOneY<0:
        Ychange *=-1 # This changes the movement of girl in opposite direction

    if girlOneY>=480: #This checks if the girl has reached around the CEO
        # Right now, for reference. We will print the Game Over
        # print("Game Over")
        isGameOver = True
    elif girlOneX>(blockX+changeX) and girlOneX<(blockX+changeX+254) and girlOneY>=425: #To check if the girl has touched the block
        Ychange*=-1
        # Increasing the score
        score+=1
        # Let's play the laser sound effect
        sound = mixer.Sound('laser.wav')
        sound.play()
    
    displayScore(score)
    if (isGameOver):
        game_over()
    else:
        # Now let's do, screen.blit()
        screen.blit(girlOne,(girlOneX,girlOneY))
        screen.blit(block, (blockX, blockY))
        # We use screen.blit() to place our image inside our game window
        screen.blit(ceo, (375,540)) # After adjusting, I found this coordinate to set our CEO in the very Bottom-Center.


    # And to Update, we will write the following code in the very end of the game loop.
    pygame.display.update()

Output

output for Complete Game In PyGame and Python

So, that is it. We have finally created this fully-featured Complete Game In PyGame and Python.

End of our PyGame Series

So yeah, finally we have reached the end of this series. Hope you found something incredible here. From the very first article, about what is pygame to creating a fully-featured game using pygame and python.

The final game that we had made in the last article, was built in such a way that, it becomes easy for the reader to understand and had all the features of pygame, that we have talked about in our articles.

We know, that python is very vast. And the pygame tutorial that we did right now, can be used to create so many magnificent things. You can create games, like among us using networking and add machine learning… all inside your 2-D game, because we saw that pygame just gives us so much control on our game objects. And all the thing that creates a game robust, is the logic that it follows.



Here are some tips and tricks for you:

Source of this information is pygame docs.

1. Get comfortable working in Python

The most important thing is to feel confident using python. Learning something as potentially complicated as graphics programming will be a real chore if you’re also unfamiliar with the language you’re using. Write a few sizable non-graphical programs in python — parse some text files, write a guessing game or a journal-entry program or something.

Get comfortable with string and list manipulation — know how to split, slice, and combine strings and lists. Know how import works — try writing a program that is spread across several source files.

Write your own functions, and practice manipulating numbers and characters; know how to convert between the two. Get to the point where the syntax for using lists and dictionaries is second-nature — you don’t want to have to run to the documentation every time you need to slice a list or sort a set of keys.

Resist the temptation to run to a mailing list, comp.lang.python, or IRC when you run into trouble. Instead, fire up the interpreter and play with the problem for a few hours.

This may sound incredibly dull, but the confidence you’ll gain through your familiarity with python will work wonders when it comes time to write your game. The time you spend making python code second-nature will be nothing compared to the time you’ll save when you’re writing real code.

2. Recognize which parts of pygame you really need

Looking at the jumble of classes at the top of the pygame Documentation index may be confusing. The important thing is to realize that you can do a great deal with only a tiny subset of functions. Many classes you’ll probably never use.

3. Don’t get distracted by side issues

Sometimes, new game programmers spend too much time worrying about issues that aren’t really critical to their game’s success. The desire to get secondary issues ‘right’ is understandable, but early in the process of creating a game, you cannot even know what the important questions are, let alone what answers you should choose. The result can be a lot of needless prevarication.

For example, consider the question of how to organize your graphics files. Should each frame have its own graphics file, or each sprite? Perhaps all the graphics should be zipped up into one archive? A great deal of time has been wasted on a lot of projects, asking these questions on mailing lists, debating the answers, profiling, etc, etc. This is a secondary issue; any time spent discussing it should have been spent coding the actual game.

The insight here is that it is far better to have a ‘pretty good’ solution that was actually implemented, than a perfect solution that you never got around to writing.



4. Don’t bother with pixel-perfect collision detection.

So you’ve got your sprites moving around, and you need to know whether or not they’re bumping into one another. It’s tempting to write something like the following:

  • Check to see if the rects are in collision. If they aren’t, ignore them.
  • For each pixel in the overlapping area, see if the corresponding pixels from both sprites are opaque. If so, there’s a collision.

There are other ways to do this, with ANDing sprite masks and so on, but anyway you do it in pygame, it’s probably going to be too slow. For most games, it’s probably better just to do ‘sub-rect collision’ — create a rect for each sprite that’s a little smaller than the actual image, and use that for collisions instead. It will be much faster, and in most cases, the player won’t notice the imprecision.

5. Know what a surface is

The most important part of pygame is the surface. Just think of a surface as a blank piece of paper. You can do a lot of things with a surface — you can draw lines on it, fill parts of it with color, copy images to and from it, and set or read individual pixel colors on it. A surface can be any size (within reason) and you can have as many of them as you like (again, within reason).

One surface is special — the one you create with pygame.display.set_mode(). This ‘display surface’ represents the screen; whatever you do to it will appear on the user’s screen. You can only have one of these — that’s an SDL limitation, not a pygame one.

So how do you create surfaces? As mentioned above, you create the special ‘display surface’ with pygame.display.set_mode(). You can create a surface that contains an image by using image.load(), or you can make a surface that contains text with font.render(). You can even create a surface that contains nothing at all with Surface().

Most of the surface functions are not critical. Just learn blit()fill()set_at() and get_at(), and you’ll be fine.


Also Read:


  • Games in Python | Assignment Expert
  • Creating a Pong Game using Python Turtle
    Introduction 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 PyGame
    We 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 Projects
    Without 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 code
    OVERVIEW 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 PyGame
    So 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 Python
    Now, 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 Pygame
    Now, 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 Project
    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…
  • Car Race Game in PyGame Python: From Scratch
    Check 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 PyGame
    So, 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…
  • Moving an object in PyGame|Python
    Now as we have learned how to add images, we can finally bring the mechanics/movement to our game elements using pygame. So, the aim of this article is to make you learn how to make PyGame elements moving or Moving an object in PyGame. All in all, we will learn how to move an image…
  • Display Images with Pygame|Python
    Now comes the most exciting part. In this article, we will be Display Images with Pygame. So, one of the most important things that you need to move further in this tutorial is of-course images. To download free icons, we can use Flaticon. Flaticon offers a wide catalog of free icons. When you perform a search, there will…
  • Customize the Pygame Window|Python
    In the previous article, we learned how to create a game window using pygame and python. But it was definitely not what we all wanted. Of course, we need to Customize the Pygame Window by adding a background color, change the title, and adding an icon. So in this article, we will learn how to…
  • Getting Started with Pygame
    To get started with Pygame, you need to install Pygame library in your system. Pygame requires Python, so make sure that you have Python 3.7.7 or greater, because it is much friendlier to beginners and it also runs faster than the previous versions. Using pip tool The best way to install Pygame in your computer is…
  • What is Pygame? Full Introduction
    Gaming has been fun for all of us since childhood. We all enjoy playing games. But almost all the games that we have played yet were made by someone else. But you know what would be really cool? Creating your own game. Don’t worry if you don’t know how to make one. We are here…

Browse Post tags-

Share:

Author: Ayush Purawr