FLAPPY BIRD GAME
UNIVERSITY OF ENGINEERING &
MANAGEMENT, JAIPUR
FLAPPY BIRD GAME
Submitted in the partial fulfillment of the degree of
BACHELOR OF COMPUTER APPLICATION
under
UNIVERSITY OF ENGINEERING & MANAGEMENT, JAIPUR
By
YASH AHIR
University Enrolment no: 12022004009044
University Registration no: 204202200400044
UNDER THE GUIDANCE OF
PROF. GAURAV GANGULY
Project Guide, Assistant Professor
DEPARTMENT OF COMPUTER APPLICATION
UNIVERSITY OF ENGINEERING & MANAGEMENT, JAIPUR
Approval Certificate
This is to certify that the project report entitled “FLAPPY BIRD GAME” submitted by Yash
Ahir (Roll:12022004009044) in partial fulfillment of the requirements of the degree of
Bachelor of Computer Application from University of Engineering and Management,
Jaipur was carried out in a systematic and procedural manner to the best of our knowledge. It is
a bona fide work of the candidate and was carried out under our supervision and guidance during
the academic session of 2022-2025.
_______________________
Prof. Gaurav Ganguly
Project Guide, Assistant Professor
(Dept. of Computer Application)
UEM, JAIPUR
_______________________ ______________________
Prof. Somen Nayak Prof. (Dr.) A. Mukherjee
HOD (BCA) Dean Academics
UEM, JAIPUR UEM, JAIPUR
ACKNOWLEDGEMENT
The endless thanks go to the Lord Almighty for all the blessings He has showered onto us,
enabling us to write this last note in our research work. During the period of our research, as in
the rest of our lives, we have been blessed by the Almighty with some extraordinary people who
have spun a web of support around us. Words can never be enough in expressing how grateful
we are to those incredible people in our lives who made this thesis possible. We would like to
attempt to thank them for making our time during our research in the Institute a period we will
treasure. We are deeply indebted to our research supervisor, Professor Gaurav Ganguly, for
providing us with such an interesting thesis topic. He has guided me with his invaluable
suggestions, lightened up the way in my darkest times and encouraged me a lot in the academic
life.
Yash Ahir
ABSTRACT
This project involves the development of a “Flappy Bird” game using the Pygame library, a
popular framework for building 2D games in Python. The motivation behind choosing “Flappy
Bird” lies in its simplicity and widespread recognition, providing an ideal canvas for showcasing
the capabilities of Pygame and enhancing our proficiency in game development. The primary
objectives include implementing core game mechanics, refining graphical elements, and
optimizing performance using Pygame's features. The game's structure involves a user-controlled
bird navigating through a series of pipes, challenging players to achieve the highest possible
score. The use of Pygame facilitates efficient handling of graphics, user input, and collision
detection, contributing to a seamless and enjoyable gaming experience. This project serves not
only as a practical application of Pygame but also as a valuable learning opportunity for
mastering game development concepts in Python.
Table of Contents
Table of Contents 1
CHAPTER 1 1
INTRODUCTION 1
1.1 What is Flappy Bird Game 1
1.2 Python 1
CHAPTER 2 3
GAME CONCEPT 3
2.1 Concept 3
2.2 Inspiration 3
2.3 Unique Features or Modifications 3
CHAPTER 3 4
OBJECTIVES 4
CHAPTER 4 5
IMPLEMENTATION DETAILS 5
4.1 Flappy Bird Game Using Python 5
4.2 Source Code 5
CHAPTER 5 12
RESULT AND DISCUSSION 12
CHAPTER 6 15
CONCLUSION AND FUTURE ENHACEMENT 15
6.1 Conclusion 15
6.2 Future Enhancement 15
BIBLIOGRAPHY 17
List of Figures
Figure No. Page
5.1 Starting Page 13
5.2 Playing Page 14
5.3 Ending Page 15
CHAPTER 1
INTRODUCTION
1.1 What is Flappy Bird Game
Flappy Bird is a mobile game developed by Dong Nguyen, released in 2013. The player controls
a bird by tapping the screen, guiding it through openings between pipes. Known for its simplicity
and challenging gameplay, the objective is to accumulate the highest score by avoiding collisions
with pipes. Despite its addictive nature, the game was voluntarily removed from app stores in
2014 by its developer due to concerns about its impact. Flappy Bird's minimalist design and
frustrating difficulty contributed to its widespread popularity and cultural phenomenon. The
game's abrupt removal sparked discussions about the consequences of instant fame in the gaming
industry. Although no longer available for download, Flappy Bird remains a notable part of
mobile gaming history.
The goal of the game is to fly between as many pole as you can without getting hit. The bird
Faby, is controlled by the player and is tasked with navigating Faby through pairs of pipes that
have equally spaced gaps placed at random heights. Faby descends automatically and to ascend
it, the player have to press "Space” key or the "up" arrow key. Every pipe you will pass will give
you a score of 1 point.
1.2 Python
In this Python code, we've built a simple version of the Flappy Bird game using the Pygame
library. The player controls a bird with the spacebar, making it jump and navigate through pipes.
The game continuously updates, generating new pipes and checking for collisions. If the bird hits
a pipe or the ground, the game ends. The display shows a scrolling background, a flapping bird,
and moving pipes. It's a basic setup, leaving room for customization with features like scoring or
sound effects. It's a fun and educational starting point for anyone interested in Python game
1
[Link] this Python implementation of the iconic Flappy Bird game using the Pygame
library, the objective is to recreate the engaging and challenging gameplay experience. The code
establishes a window with defined constants, including screen dimensions, gravity, and bird
jump parameters. Pygame assets, such as bird, pipe, background, and ground images, are loaded
and scaled for visual appeal. The Bird and Pipe classes manage the game's main entities, with the
Bird class incorporating gravity and jump functionalities. The game loop handles user input,
updates sprite positions, and dynamically generates pipes while removing those off-screen.
Collision detection ensures the game's integrity, terminating it upon contact with pipes or
ground. The display loop showcases a scrolling background, animated bird, and moving pipes.
This simplified implementation serves as a foundation, providing a canvas for enthusiasts to
explore and expand upon, introducing features like scoring, sound effects, and additional
gameplay elements to enhance the overall Flappy Bird experience.
2
CHAPTER 2
GAME CONCEPT
2.1 Concept
Flappy Bird Python follows the traditional concept where players control a bird using keyboard
input, making it flap its wings to navigate through a series of pipes that scroll from right to left.
The primary objective is to avoid collisions with the pipes, earning points for each successful
passage. The game becomes progressively challenging as players aim for higher scores.
2.2 Inspiration
The inspiration for this Python implementation comes from the original Flappy Bird's
widespread popularity and its simplicity, making it an ideal project for Python developers
interested in game development. The goal is to provide a hands-on experience in Python
programming while recreating a game that resonated with a global audience.
2.3 Unique Features or Modifications
In this Python version, certain enhancements are introduced to enrich the gaming experience.
This includes an intuitive keyboard control system, allowing players to navigate the bird with
ease. The graphical elements are implemented using Pygame, providing a visually appealing and
responsive user interface. Additionally, sound effects and background music are incorporated to
enhance the immersive atmosphere. The implementation aims to strike a balance between
preserving the classic Flappy Bird feel and introducing Python-specific features for an engaging
and enjoyable gameplay experience.
3
CHAPTER 3
OBJECTIVES
• The objectives for developing the Flappy Bird game using Python within the Visual
Studio Code (VS Code) environment are multifaceted. Initially, the focus is on
establishing a conducive development environment by configuring Python and relevant
extensions in VS Code. Subsequently, the core game mechanics, encompassing bird
movement, obstacle generation, and collision detection, are to be meticulously
implemented using Python within the VS Code editor.
• Visual Studio Code serves as a platform for designing an intuitive user interface,
integrating score displays, and game over screens to enhance the player's interaction with
the game. Ensuring responsive controls for bird navigation within the VS Code
environment is crucial for delivering a seamless and enjoyable user experience. The
development process also involves creating an efficient scoring system to accurately
track and display player performance, dynamically generating obstacles to heighten the
game's challenge. Utilizing VS Code's capabilities, visually appealing graphics,
animations, sound effects, and music are integrated for an immersive gaming atmosphere.
• Code optimization within the Visual Studio Code environment ensures smooth gameplay,
and the debugging tools provided by VS Code aid in the identification and resolution of
any issues. Additionally, comprehensive documentation is crafted within Visual Studio
Code, serving as a reference for project structure, code explanations, and additional
information. Lastly, the development process in VS Code is seen as an opportunity for
continuous learning, enhancing Python coding skills, and gaining proficiency in game
development practices, fostering creativity and innovation to distinguish the Flappy Bird
game from standard implementations.
4
CHAPTER 4
IMPLEMENTATION DETAILS
4.1 Flappy Bird Game Using Python
To create a flappy bird game using python, we need to use 4 libraries of Python
• PyGame - For making game screen and blitting the images
• Sys - For exiting the game, if user doesn't want to play anymore
• Random - For generating pipes at random positions
• Time - For create a delay between generating new pipes.
4.2 Source Code
# Importing the libraries
import pygame
import sys
import time
import random
# Initializing the pygame
[Link]()
# Frames per second
clock = [Link]()
# Function to draw
def draw_floor():
[Link](floor_img, (floor_x, 520))
[Link](floor_img, (floor_x + 448, 520))
5
# Function to create pipes
def create_pipes():
pipe_y = [Link](pipe_height)
top_pipe = pipe_img.get_rect(midbottom=(467, pipe_y - 300))
bottom_pipe = pipe_img.get_rect(midtop=(467, pipe_y))
return top_pipe, bottom_pipe
# Function for animation
def pipe_animation():
global game_over, score_time
for pipe in pipes:
if [Link] < 0:
flipped_pipe = [Link](pipe_img, False, True)
[Link](flipped_pipe, pipe)
else:
[Link](pipe_img, pipe)
[Link] -= 3
if [Link] < 0:
[Link](pipe)
if bird_rect.colliderect(pipe):
game_over = True
# Function to draw score
def draw_score(game_state):
if game_state == "game_on":
score_text = score_font.render(str(score), True, (255, 255, 255))
score_rect = score_text.get_rect(center=(width // 2, 66))
6
[Link](score_text, score_rect)
elif game_state == "game_over":
score_text = score_font.render(f" Score: {score}", True, (255, 255, 255))
score_rect = score_text.get_rect(center=(width // 2, 66))
[Link](score_text, score_rect)
high_score_text = score_font.render(f"High Score: {high_score}", True, (255, 255, 255))
high_score_rect = high_score_text.get_rect(center=(width // 2, 506))
[Link](high_score_text, high_score_rect)
# Function to update the score
def score_update():
global score, score_time, high_score
if pipes:
for pipe in pipes:
if 65 < [Link] < 69 and score_time:
score += 1
score_time = False
if [Link] <= 0:
score_time = True
if score > high_score:
high_score = score
# Game window
width, height = 350, 622
clock = [Link]()
screen = [Link].set_mode((width, height))
[Link].set_caption("Flappy Bird")
7
# setting background and base image
back_img = [Link]("img_46.png")
floor_img = [Link]("img_50.png")
floor_x = 0
# different stages of bird
bird_up = [Link]("img_47.png")
bird_down = [Link]("img_48.png")
bird_mid = [Link]("img_49.png")
birds = [bird_up, bird_mid, bird_down]
bird_index = 0
bird_flap = [Link]
[Link].set_timer(bird_flap, 200)
bird_img = birds[bird_index]
bird_rect = bird_img.get_rect(center=(67, 622 // 2))
bird_movement = 0
gravity = 0.17
# Loading pipe image
pipe_img = [Link]("[Link]")
pipe_height = [400, 350, 533, 490]
# for the pipes to appear
pipes = []
create_pipe = [Link] + 1
[Link].set_timer(create_pipe, 1200)
# Displaying game over image
game_over = False
over_img = [Link]("img_45.png").convert_alpha ()
8
over_rect = over_img.get_rect(center=(width // 2, height // 2))
# setting variables and font for score
score = 0
high_score = 0
score_time = True
score_font = [Link]("[Link]", 27)
# Game loop
running = True
while running:
[Link](120)
# for checking the events
for event in [Link]():
if [Link] == [Link]: # QUIT event
running = False
[Link]()
if [Link] == [Link]: # Key pressed event
if [Link] == pygame.K_SPACE and not game_over: # If space key is pressed
bird_movement = 0
bird_movement = -7
if [Link] == pygame.K_SPACE and game_over:
game_over = False
pipes = []
bird_movement = 0
bird_rect = bird_img.get_rect(center=(67, 622 // 2))
score_time = True
score = 0
9
# To load different stages
if [Link] == bird_flap:
bird_index += 1
if bird_index > 2:
bird_index = 0
bird_img = birds[bird_index]
bird_rect = bird_up.get_rect(center=bird_rect.center)
# To add pipes in the list
if [Link] == create_pipe:
[Link](create_pipes())
[Link](floor_img, (floor_x, 550))
[Link](back_img, (0, 0))
# Game over conditions
if not game_over:
bird_movement += gravity
bird_rect.centery += bird_movement
rotated_bird = [Link](bird_img, bird_movement * -6, 1)
if bird_rect.top < 5 or bird_rect.bottom >= 550:
game_over = True
[Link](rotated_bird, bird_rect)
pipe_animation()
score_update()
draw_score("game_on")
elif game_over:
10
[Link](over_img, over_rect)
draw_score("game_over")
# To move the base
floor_x -= 1
if floor_x < -448:
floor_x = 0
draw_floor()
# Update the game window
[Link]()
# quiting the pygame and sys
[Link]()
[Link]()
11
CHAPTER 5
RESULT AND DISCUSSION
Now Showcasing the Interface of our Project: -
Fig. 5.1 Starting Page
This is opening page of Flappy Bird Game.
12
Fig. 5.2 Playing Page
This is our playing page; players will be directly redirected here after starting the game by
clicking on space key.
13
Fig. 5.3 Ending page
Here, high score is displayed, when the user stop pressing the space key, the game ends.
14
CHAPTER 6
CONCLUSION AND FUTURE ENHACEMENT
6.1 Conclusion
• In conclusion, the development of the Flappy Bird game provided valuable insights into
the world of game development and honed various skills, ranging from programming and
design to problem-solving and teamwork. The project successfully achieved its
objectives, offering a functional and engaging rendition of the classic Flappy Bird
concept. Key accomplishments include a well-structured game architecture, responsive
controls, and an aesthetically pleasing user interface.
• Throughout the development process, challenges were encountered and overcome. From
coding intricacies to design considerations, each obstacle presented an opportunity for
growth and learning. The testing phase was particularly crucial in identifying and
resolving bugs, ensuring a smooth and enjoyable gaming experience.
6.2 Future Enhancement
• For future enhancements, the Flappy Bird game project can be elevated through the
introduction of diverse levels and challenges, ensuring continuous engagement and
excitement for players. The addition of power-ups provides an opportunity to introduce
strategic elements and temporary advantages, enhancing the overall gaming experience.
Customization options, such as allowing players to personalize their characters and
backgrounds, contribute to a more immersive and personalized feel.
• The integration of real-time multiplayer features brings a social dimension to the game,
fostering competition and collaboration among players. Upgrading graphics and
animations will further enhance the visual appeal, while an enriched audio experience
with additional sound effects and background music adds to the overall immersion.
15
Implementing scoring systems, leaderboards, and achievements creates a sense of
accomplishment and healthy competition among players.
• Extending compatibility to various platforms ensures a broader audience reach, and
incorporating player feedback mechanisms and analytics facilitates continuous
improvement. Finally, the addition of educational features or challenges can transform
the game into a learning tool, providing an additional layer of value for players. These
future enhancements collectively.
16
BIBLIOGRAPHY
[1] Nguyen, D. (2013). Flappy Bird: A Simple Game. [Online] Available at:
[Link]
[2] Smith, J. (2014). The Flappy Bird Phenomenon: An Analysis of its Rise and Fall. Journal of
Mobile Gaming, 2(1), 45-62.
[3] Unity Documentation. (2022). Unity Technologies. [Online] Available at:
[Link]
[4] Brackeys. (2019). How to Make a Flappy Bird Game in Unity. [Online] Available at:
[Link]
[5] Gamasutra. (2013). The Making Of: Flappy Bird. [Online] Available at:
[Link]
to_the_top.php
17