0% found this document useful (0 votes)
1 views19 pages

Python Report Submit

The document is a mini project report on the development of the 'Flappy Bird Game' using Python and the Pygame library, submitted by a team of students from K. K. Wagh Institute of Engineering Education & Research. It includes sections such as an abstract, introduction, methodology, requirements, data flow diagrams, sample code, and acknowledgments. The project aims to recreate the popular mobile game, focusing on game mechanics, user input handling, and scoring systems.

Uploaded by

yogeshgavit208
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views19 pages

Python Report Submit

The document is a mini project report on the development of the 'Flappy Bird Game' using Python and the Pygame library, submitted by a team of students from K. K. Wagh Institute of Engineering Education & Research. It includes sections such as an abstract, introduction, methodology, requirements, data flow diagrams, sample code, and acknowledgments. The project aims to recreate the popular mobile game, focusing on game mechanics, user input handling, and scoring systems.

Uploaded by

yogeshgavit208
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

MINI PROJECT REPORT

ON
“Flappy Bird Game”
as a part of
Project Based Learning

Submitted by
Vaibhav Jadhav
Gautam Joshi
Manish Khonde
Santosh Shimpankar

Guided by
Prof. Poonam Patil

Master of Computer Applications


(Under Faculty of Engineering)

Department of MCA
K. K. Wagh Institute of Engineering Education & Research
Hirabai Haridas Vidyanagari, Amrutdham, Panchavati,
Nashik – 422 003

1
K. K. WAGH INSTITUTE OF ENGINEERING EDUCATION &
RESEARCH
NASHIK - 422003

CERTIFICATE
This is to certify that

Vaibhav Jadhav
Gautam Joshi
Manish Khonde
Santosh Shimpankar

Has successfully completed the Mini Project on

“Flappy Bird Game”


As a part of
Project Based Learning

During academic year 2022 – 23

Prof. Poonam Patil Prof. V. C. Bagal Dr. K. N. Nandurkar


Project Guide I/c Head, Principal
Dept. of MCA

2
Index

Title Page no.

1. Abstract 4

2. Introduction 5

3. Methodology 6

4. Requirements 8

5. Data flow diagram 10

6. Sample code 13

7. Screenshots 14

8. Conclusion 18

9. Acknowledgment 19

10. Reference 20

3
Abstract
Flappy Bird Game

Flappy Bird is a classic arcade game that has been recreated using the Python programming language
and the Pygame library. The aim of the game is to fly a bird through a series of pipes without hitting
them. The player must time their taps of the spacebar to make the bird flap its wings and move forward.
The game consists of a single-screen environment where the bird moves from left to right across the
screen. The player must time their taps of the spacebar in order to make the bird flap its wings and fly
higher. The goal is to fly the bird through as many pipe openings as possible without hitting any of
them. The game ends when the bird hits a pipe or the ground. The game is coded in Python using the
Pygame library. The game consists of a window where the graphics and animation are rendered. The
game logic is handled by two classes: the Game class, which manages the main game loop and handles
user input, and the Bird class, which manages the bird's position and velocity. There are also a few
other classes that handle the pipe generation, scoring, and collision detection. The game is divided into
several levels, with each level having a different difficulty. The game keeps track of the player's score
and high score

Keywords: Python, pygame.

(Division – B)
Team Members:
61 : Shimpankar Santosh
30 : Khonde Manish
26 : Joshi Gautam
24 : Jadhav Vaibhav

Introduction

4
Flappy Bird is a popular mobile game that gained huge popularity in early 2014. It was
developed by Dong Nguyen, a Vietnamese developer, and released for iOS and Android
platforms. The game's simple yet addictive gameplay involves controlling a bird by
tapping the screen to keep it flying and avoiding pipes in its path.

Flappy Bird became an instant hit, garnering millions of downloads and earning Nguyen
a considerable amount of money. However, he eventually took the game down from the
app stores, citing its addictive nature and the pressure that came with its success.

Despite its short-lived availability, Flappy Bird remains a cultural phenomenon and has
inspired many clones and parodies. In this context, creating a Flappy Bird game in
Python can be a fun and exciting challenge for programmers, allowing them to practice
their skills in game development and explore the basics of game physics and user input
handling.

5
Methodology
Python Modules:
1) PyGame :-

Pygame is a free and open-source cross-platform library for the development of multimedia
applications like video games using Python. It uses the Simple DirectMedia Layer library and several
other popular libraries to abstract the most common functions, making writing these programs a more
intuitive task.Tkinter is not a thin wrapper, but adds a fair amount of its own logic to make the
experience more pythonic.

Pygame is a powerful library for game development, offering a wide range of features to simplify your
coding journey. Let’s delve into what Pygame has to offer:

Graphics: With Pygame, creating dynamic and engaging graphics has never been easier. The library
provides simple yet effective tools for 2D graphics and animation, including support for images,
rectangles, and polygon shapes. Whether you’re a seasoned game developer or just starting out, Pygame
has you covered.

Sound: Pygame also includes support for playing and manipulating sound and music, making it easy to
add sound effects and background music to your games. With support for WAV, MP3, and OGG file
formats, you have plenty of options to choose from.

Input: Pygame provides intuitive functions for handling keyboard, mouse, and joystick input, allowing
you to quickly and easily implement player controls in your games. No more struggling with complex
input code, Pygame makes it simple.

Game Development: Lastly, Pygame provides a comprehensive suite of tools and features specifically
designed for game development. From collision detection to sprite management, Pygame has
everything you need to create exciting and engaging games. Whether you’re building a platformer,
puzzle game, or anything in between, Pygame has you covered.

2) Random:-

The Random module contains some very useful functions namely randint() function, random()
function, choice() function, randrange() function and shuffle() function.

The random module in Python is used to generate random numbers and make random selections from
sequences. The module uses a pseudorandom number generator to generate random numbers. A
pseudorandom number generator is an algorithm that generates numbers that appear to be random but
are actually determined by a starting value called a seed.
The random module uses a seed value to generate random numbers. By default, the seed value is based
on the current time and is different each time the program is run. However, you can also set the seed
value manually using the seed() function. If you set the seed value to a fixed value, you will get the
same sequence of random numbers every time you run the program.

6
3) Itertools:-

itertools is a Python module that provides a set of functions for working with iterable objects. The
module contains a collection of tools for handling iterators, such as infinite iterators, permutations, and
combinations. It is a powerful and efficient toolset for creating complex data pipelines.Here are some
commonly used functions in the itertools module:
1. count(start=0, step=1) - This function returns an infinite iterator that generates numbers starting
from start and incrementing by step for each iteration.
2. cycle(iterable) - This function returns an infinite iterator that cycles through the elements of the
given iterable.
3. repeat(elem, n=None) - This function returns an iterator that repeats the element elem n times or
indefinitely if n is None.
4. chain(*iterables) - This function returns an iterator that chains together the elements of the given
iterables.
5. zip_longest(*iterables, fillvalue=None) - This function returns an iterator that aggregates the
elements of the given iterables, filling in missing values with the fillvalue argument.
6. permutations(iterable, r=None) - This function returns an iterator that generates all possible
permutations of the elements of the given iterable.
7. combinations(iterable, r) - This function returns an iterator that generates all possible
combinations of r elements from the given iterable.
8. product(*iterables, repeat=1) - This function returns an iterator that generates the Cartesian
product of the given iterables.
The itertools module can be used to write efficient and concise code for tasks such as data
processing, mathematical computations, and algorithmic problem-solving. It is particularly
useful for working with large datasets or complex data structures.

7
Requirements
System
Requirements

The system requirements for an Flappy Bird game in Python will depend on the complexity of
the game and the libraries used to develop it. However, for a basic Flappy Bird game, the
following system requirements are recommended:
1. Operating System: Any modern operating system such as Windows, macOS, or Linux.
2. Processor: Any processor that supports Python 3.x. For a basic game, a CPU with a clock
speed of 1 GHz or higher should suffice.
3. Memory (RAM): At least 2 GB of RAM is recommended for smooth performance.
4. Storage: The game itself requires very little storage space, but some additional space will be
needed to store sound effects or other assets.
5. Python version: Python 3.x should be installed on the system.
6. Python libraries: The game may use libraries such as Pygame, which will need to be installed.
7. Graphics card: A dedicated graphics card is not required for a basic game, but it can improve
the game's performance and visual quality.
It's important to note that these are just general guidelines, and the exact system requirements
will depend on the specific requirements of the game being developed. Additionally, if the
game is intended to run on mobile devices or tablets, the system requirements will differ from
those of a desktop or laptop computer.

.
Software Requirements

To develop an Flappy Bird game in Python, you will need a few software requirements.
These include:
1. Python - You will need to have Python installed on your computer. Python is a free and open-
source program
2. ing language, and you can download the latest version from the official website.
3. Pygame - Pygame is a set of Python modules designed for writing games. It provides functions
to handle graphics, sound, input, and other game-related tasks. You can install Pygame using
pip, the Python package installer.
4. Code editor - You will need a code editor to write and edit the Python code. There are many
code editors available, including Visual Studio Code, PyCharm, and Sublime Text, among
others. You can choose the one that best suits your needs.
5. Sound editor - You may also need a sound editor to create or edit sound effects for your game.
There are many sound editors available, such as Audacity, which is a free, open-source sound
editor.
6. Graphics editor - You may also need a graphics editor to create or edit graphics for your game.
There are many graphics editors available, such as GIMP, which is a free, open-source graphics
editor

8
Functional Requirements

The functional requirements of an Flappy Bird game in Python define what the game should be
able to do and how it should behave. Here are some common functional requirements for an
Flappy Bird game:

1. Start screen - The game should display a start screen that provides instructions on how to play
the game and allows the player to start a new game.

2. Bird movement - The game should allow the player to move the Bird horizontally using the
Space keys or other input methods.

3. Scoring - The game should keep track of the player's score and display it on the screen.

4. Lives - The game should allow the player to have a certain number of lives, and the player loses
a life when an Bird hits the ground.

5. Game over screen - The game should display a game over screen when the player has lost all
their lives.

6. High scores - The game should keep track of the highest score achieved by the player and
display it on the screen.

These are some common functional requirements for an flappy Bird game in Python. Depending
on the specific design of the game, there may be additional or different requirements.
.

9
Data Flow Diagram

1) FLOWCHART

Start
|
v
Display Start Screen
|
v
Wait for User Input (Start Game or Quit)
|
v
While Lives > 0:
|
|__> Bird Flying
|__> Bird Flying and Cross Pipe
|__> Check for Bird Collision
|__> If Collision, Game end
|__> If Bird Hits Ground, Lose Life
|__> Update Score and Lives on Screen
|
v
Display Game Over Screen and Final Score
|
v
Wait for User Input (Restart or Quit)
|
v
End

1
0
2) Use case diagram

USER

START THE GAME

FLYING BIRD

TRY TO CROSS
PIPE

INCREASE THE
SCORE

LOSE A LIFE

GAME OVER (NO


MORE LIVES)

END

RESTART THE
GAME

1
1
SAMPLE CODE
mport random # For generating random numbers
import sys # We will use sys.exit to exit the program
import pygame
from pygame.locals import * # Basic pygame imports

# Global Variables for the game


FPS = 32
SCREENWIDTH = 289
SCREENHEIGHT = 511
SCREEN = pygame.display.set_mode((SCREENWIDTH, SCREENHEIGHT))
GROUNDY = SCREENHEIGHT * 0.8
GAME_SPRITES = {}
GAME_SOUNDS = {}
PLAYER = 'gallery/sprites/bird.png'
BACKGROUND = 'gallery/sprites/background.png'
PIPE = 'gallery/sprites/pipe.png'

def welcomeScreen():
"""
Shows welcome images on the screen
"""

playerx = int(SCREENWIDTH/5)
playery = int((SCREENHEIGHT - GAME_SPRITES['player'].get_height())/2)
messagex = int((SCREENWIDTH - GAME_SPRITES['message'].get_width())/2)
messagey = int(SCREENHEIGHT*0.13)
basex = 0
while True:
for event in pygame.event.get():
# if user clicks on cross button, close the game
if event.type == QUIT or (event.type==KEYDOWN and event.key ==
K_ESCAPE):
pygame.quit()
sys.exit()

# If the user presses space or up key, start the game for them
elif event.type==KEYDOWN and (event.key==K_SPACE or event.key == K_UP):
return
else:
SCREEN.blit(GAME_SPRITES['background'], (0, 0))
SCREEN.blit(GAME_SPRITES['player'], (playerx, playery))
SCREEN.blit(GAME_SPRITES['message'], (messagex,messagey ))
SCREEN.blit(GAME_SPRITES['base'], (basex, GROUNDY))
pygame.display.update() # To Change the screen
FPSCLOCK.tick(FPS) #to control fps

def mainGame():
score = 0
playerx = int(SCREENWIDTH/5)
playery = int(SCREENWIDTH/2)
basex = 0

# Create 2 pipes for blitting on the screen


newPipe1 = getRandomPipe()
newPipe2 = getRandomPipe()

# my List of upper pipes


upperPipes = [
{'x': SCREENWIDTH+200, 'y':newPipe1[0]['y']},
1
2
{'x': SCREENWIDTH+200+(SCREENWIDTH/2), 'y':newPipe2[0]['y']},
]
# my List of lower pipes
lowerPipes = [
{'x': SCREENWIDTH+200, 'y':newPipe1[1]['y']},
{'x': SCREENWIDTH+200+(SCREENWIDTH/2), 'y':newPipe2[1]['y']},
]

pipeVelX = -4 # for a pipe create illusion

playerVelY = -9
playerMaxVelY = 10
playerMinVelY = -8
playerAccY = 1

playerFlapAccv = -8 # velocity while flapping


playerFlapped = False # It is true only when the bird is flapping

while True:
for event in pygame.event.get():
if event.type == QUIT or (event.type == KEYDOWN and event.key ==
K_ESCAPE):
pygame.quit()
sys.exit()
if event.type == KEYDOWN and (event.key == K_SPACE or event.key ==
K_UP):
if playery > 0:
playerVelY = playerFlapAccv
playerFlapped = True
GAME_SOUNDS['wing'].play()

crashTest = isCollide(playerx, playery, upperPipes, lowerPipes) # This


function will return true if the player is crashed
if crashTest:
return

#check for score


playerMidPos = playerx + GAME_SPRITES['player'].get_width()/2
for pipe in upperPipes:
pipeMidPos = pipe['x'] + GAME_SPRITES['pipe'][0].get_width()/2
if pipeMidPos<= playerMidPos < pipeMidPos +4:
score +=1
print(f"Your score is {score}")
GAME_SOUNDS['point'].play()

if playerVelY <playerMaxVelY and not playerFlapped:


playerVelY += playerAccY

if playerFlapped:
playerFlapped = False
playerHeight = GAME_SPRITES['player'].get_height()
playery = playery + min(playerVelY, GROUNDY - playery - playerHeight)

# move pipes to the left


for upperPipe , lowerPipe in zip(upperPipes, lowerPipes):
upperPipe['x'] += pipeVelX
lowerPipe['x'] += pipeVelX

1
3
# Add a new pipe when the first is about to cross the leftmost part of the
screen
if 0<upperPipes[0]['x']<5:
newpipe = getRandomPipe()
upperPipes.append(newpipe[0])
lowerPipes.append(newpipe[1])

# if the pipe is out of the screen, remove it


if upperPipes[0]['x'] < -GAME_SPRITES['pipe'][0].get_width():
upperPipes.pop(0)
lowerPipes.pop(0)

# Lets blit our sprites now


SCREEN.blit(GAME_SPRITES['background'], (0, 0))
for upperPipe, lowerPipe in zip(upperPipes, lowerPipes):
SCREEN.blit(GAME_SPRITES['pipe'][0], (upperPipe['x'], upperPipe['y']))
SCREEN.blit(GAME_SPRITES['pipe'][1], (lowerPipe['x'], lowerPipe['y']))

SCREEN.blit(GAME_SPRITES['base'], (basex, GROUNDY))


SCREEN.blit(GAME_SPRITES['player'], (playerx, playery))
myDigits = [int(x) for x in list(str(score))]
width = 0
for digit in myDigits:
width += GAME_SPRITES['numbers'][digit].get_width()
Xoffset = (SCREENWIDTH - width)/2

for digit in myDigits:


SCREEN.blit(GAME_SPRITES['numbers'][digit], (Xoffset,
SCREENHEIGHT*0.12))
Xoffset += GAME_SPRITES['numbers'][digit].get_width()
pygame.display.update()
FPSCLOCK.tick(FPS)

1
4
SCREENSHOTS

CONCLUSION
1
5
In conclusion, The game's success was unprecedented, with millions of downloads and daily active
users. However, Nguyen faced criticism and controversy due to the game's addictive nature, leading
him to remove the game from app stores. The game's removal sparked a wave of clones and imitators,
but none could replicate the original's success.

Flappy Bird's success can be attributed to its simplicity and accessibility. The game was easy to learn
but challenging to master, making it appealing to a wide range of players. Additionally, the game's
difficulty and addictive nature kept players coming back for more, leading to its massive popularity.

Despite its short-lived popularity, Flappy Bird remains a cultural phenomenon and a testament to the
power of mobile gaming. Its legacy can be seen in countless imitators and the enduring appeal of
simple, addictive gameplay.

1
6
ACKNOWLEDGEMENT
We have taken efforts in this Project “Flappy Bird Game”. However, it would not have been possible
without the kind support and help of many individuals and organizations. We would like to extend
our sincere thanks to all of them.

Firstly we express our gratitude to Principle Dr. K. N. Nandurkar Sir and the project co-ordinator
Prof. Poonam Patil Mam for their support.

We would like to thank our project guide Prof. Poonam Patil Mam for guiding us throughout our
work with patience. She has taken pain to go through our project and make necessary corrections as
and when needed. Without her guidance and persistent efforts this project would not have been
possible.

We extend our gratefulness to our institute’s library and its members for their support and heartfelt
thanks to all the faculty members of the college

1
7
Reference

 Python.org
 Real python
 Pygame.org

1
8
Thank you

1
9

You might also like