How to build Flappy Bird in Python

Manpreet Singh
5 min readMay 7, 2021

Welcome back! Flappy Bird was one of the most popular mobile games ever created, so let’s go ahead and build this out. First off, we’re going to be using this specific Github project, so make sure to give them all of the credit, I am simply explaining the code out in detail, here is full project:

Within this project you will see a couple of different files, a background image, base image, the images for the bird, the actual Python file ( a pipe image and a readme file:

Awesome, we will need this folder to essentially run this whole project, make sure to keep all of these assets in the same folder. Now, we will need to install the pygame module, in order to do this run the following command:

pip install pygame
#For Python3 Use The Following
pip3 install pygame

Awesome! You could technically run the Python file right now if you wanted to by going to your terminal / command prompt and using this command:

python /path/to/the/folder/on/your/computer/
python3 /path/to/the/folder/on/your/computer/

Make sure to change the above file path to the specific one for your folder, you will essentially see the game actually output:

But before we run it, let’s walk through the code since we may need to change some things. Starting off, we’re going to import our project and set some universal characteristics of our game, these include the screen height, width, speed and many other things as well:

import pygame, random
from pygame.locals import *

SPEED = 10