class 12 computer project final documentation
class 12 computer project final documentation
1. ABSTRACT 2
2. FEASABILITY STUDY 3
3. SYSTEM REQUIREMENT 4
5. TESTING 6
6. MAINTANANCE 7
7. MODULES USED 8
8. FLOW CHART 9
9. CODING 10
11. CONCLUSION 27
12. BIBLIOGRAPHY 28
1
ABSTRACT
Flappy Bird is a straightforward and challenging mobile game
where the player controls a small, animated bird. The goal is to
guide the bird through an endless series of pipes without hitting
them or the ground. Each time the bird successfully flies
through a set of pipes, the player earns a point. However, if the
bird collides with a pipe or falls to the ground, the game ends,
and the player must start over.
2
1.FEASIBILITY STUDY
This game can be fun because it helps us reduce stress and can
challenge Friend.
It is more valuable because this game does not cost any money.
It is free thus helping people to have fun with friends which can
challenge Friend’s High score. It ask username for saving score
for Continue to beat there High Score of themselves. People can
check friend’s high score easily by CSV file.
2. SYSTEM REQUIREMENTS
3
2.1 MINIMUM:
2.2 SOFTWARE:
Python (Version 3.11 or newer)
4
An error, some times called “A Bug” is anything in the code that
prevents a program from compiling and running correctly. There
are broadly three types of errors
4. TESTING
5. MAINTENANCE
Programming maintenance refers to the modifications in the
program. After it has been completed, in order to meet
6
changing requirements or to take care of the errors that shown
up. There are four types of maintenance:
6.MODULES USED
7
First, we need to install Pygame. Think of it as the toolbox you'll
need to build your game. Pygame handles everything like
showing pictures on the screen (for the bird and pipes),
capturing key presses (so we can make the bird jump), and
playing sounds (for when the bird crashes, or you score points).
The pipes in Flappy Bird don’t always appear in the same place.
To keep things interesting, we use the random library. It allows
us to randomly generate things like the gap between the pipes
and the height of the pipes themselves, so each playthrough
feels different.
You’ll need to make sure the game closes properly when the
player decides to quit or when the bird crashes. sys is the
module that lets you do this. It will cleanly stop the game if the
player closes the window or the bird hits something it shouldn't.
8
FLOW CHART:
start
Initialize game
Variables
Display window
Check for user already 9
exists or not
Handle
events(spacebar/qui
t) Quit
Connect to database
10
SOURCE CODE
import pygame, random, time, csv
# VARIABLES
SCREEN_WIDHT = 400
SCREEN_HEIGHT = 600
SPEED = 20
GRAVITY = 2.5
GAME_SPEED = 15
GROUND_WIDHT = 2 * SCREEN_WIDHT
GROUND_HEIGHT = 100
PIPE_WIDHT = 80
PIPE_HEIGHT = 500
PIPE_GAP = 150
CSV_FILE = "highscore.csv"
11
wing = '//192.168.25.251/Class 12/12-B2/12B2 24-25/12
B2/S_hawndan_I_el.S/flappy bird/flappy bird audios/wing.wav'
# Initialize mixer
pygame.mixer.init()
def read_highscore():
try:
reader = csv.reader(file)
return int(row[0])
except FileNotFoundError:
return 0
def write_highscore(score):
writer = csv.writer(file)
12
writer.writerow([score])
high_score = read_highscore()
current_score = 0
class Bird(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.images =
[pygame.image.load('//192.168.25.251/Class 12/12-B2/12B2
24-25/12 B2/S_hawndan_I_el.S/flappy bird/bluebird-
upflap.png').convert_alpha()] * 3
self.speed = SPEED
self.current_image = 0
self.image = self.images[0]
self.mask = pygame.mask.from_surface(self.image)
self.rect = self.image.get_rect()
self.rect[0] = SCREEN_WIDHT / 6
self.rect[1] = SCREEN_HEIGHT / 2
13
def update(self):
self.current_image = (self.current_image + 1) % 3
self.image = self.images[self.current_image]
self.speed += GRAVITY
# Update height
self.rect[1] += self.speed
def bump(self):
self.speed = -SPEED
def begin(self):
self.current_image = (self.current_image + 1) % 3
self.image = self.images[self.current_image]
class Pipe(pygame.sprite.Sprite):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load('//192.168.25.251/Class
12/12-B2/12B2 24-25/12 B2/S_hawndan_I_el.S/flappy
bird/bluebird-upflap.png').convert_alpha()
14
self.image = pygame.transform.scale(self.image,
(PIPE_WIDHT, PIPE_HEIGHT))
self.rect = self.image.get_rect()
self.rect[0] = xpos
if inverted:
else:
self.mask = pygame.mask.from_surface(self.image)
def update(self):
self.rect[0] -= GAME_SPEED
class Ground(pygame.sprite.Sprite):
pygame.sprite.Sprite.__init__(self)
15
self.image = pygame.image.load('//192.168.25.251/Class
12/12-B2/12B2 24-25/12 B2/S_hawndan_I_el.S/flappy
bird/base.png').convert_alpha()
self.image = pygame.transform.scale(self.image,
(GROUND_WIDHT, GROUND_HEIGHT))
self.mask = pygame.mask.from_surface(self.image)
self.rect = self.image.get_rect()
self.rect[0] = xpos
def update(self):
self.rect[0] -= GAME_SPEED
def is_off_screen(sprite):
def get_random_pipes(xpos):
16
pygame.init()
screen = pygame.display.set_mode((SCREEN_WIDHT,
SCREEN_HEIGHT))
pygame.display.set_caption('Flappy Bird')
BACKGROUND = pygame.image.load('//192.168.25.251/Class
12/12-B2/12B2 24-25/12 B2/S_hawndan_I_el.S/flappy
bird/base.png')
BACKGROUND = pygame.transform.scale(BACKGROUND,
(SCREEN_WIDHT, SCREEN_HEIGHT))
BEGIN_IMAGE = pygame.image.load('//192.168.25.251/Class
12/12-B2/12B2 24-25/12 B2/S_hawndan_I_el.S/flappy
bird/message.png').convert_alpha()
bird_group = pygame.sprite.Group()
bird = Bird()
bird_group.add(bird)
ground_group = pygame.sprite.Group()
for i in range(2):
ground = Ground(GROUND_WIDHT * i)
ground_group.add(ground)
17
pipe_group = pygame.sprite.Group()
for i in range(2):
pipe_group.add(pipes[0])
pipe_group.add(pipes[1])
clock = pygame.time.Clock()
begin = True
while begin:
clock.tick(15)
if event.type == QUIT:
pygame.quit()
if event.type == KEYDOWN:
bird.bump()
pygame.mixer.music.load(wing)
pygame.mixer.music.play()
begin = False
18
screen.blit(BACKGROUND, (0, 0))
if is_off_screen(ground_group.sprites()[0]):
ground_group.remove(ground_group.sprites()[0])
ground_group.add(new_ground)
bird.begin()
ground_group.update()
bird_group.draw(screen)
ground_group.draw(screen)
pygame.display.update()
while True:
clock.tick(15)
if event.type == QUIT:
pygame.quit()
if event.type == KEYDOWN:
19
if event.key == K_SPACE or event.key == K_UP:
bird.bump()
pygame.mixer.music.load(wing)
pygame.mixer.music.play()
if is_off_screen(ground_group.sprites()[0]):
ground_group.remove(ground_group.sprites()[0])
ground_group.add(new_ground)
if is_off_screen(pipe_group.sprites()[0]):
pipe_group.remove(pipe_group.sprites()[0])
pipe_group.remove(pipe_group.sprites()[0])
pipes = get_random_pipes(SCREEN_WIDHT * 2)
pipe_group.add(pipes[0])
pipe_group.add(pipes[1])
bird_group.update()
20
ground_group.update()
pipe_group.update()
bird_group.draw(screen)
pipe_group.draw(screen)
ground_group.draw(screen)
pygame.display.update()
if (pygame.sprite.groupcollide(bird_group, ground_group,
False, False, pygame.sprite.collide_mask) or
pygame.sprite.groupcollide(bird_group, pipe_group,
False, False, pygame.sprite.collide_mask)):
pygame.mixer.music.load(hit)
pygame.mixer.music.play()
time.sleep(1)
high_score = current_score
write_highscore(high_score)
21
break
OUTPUT
22
23
24
25
#SAVING VALUES IN DATABASE
CONCLUSION
26
The Flappy Bird game project illustrates the intersection of
simplicity in design with engaging gameplay, demonstrating
how even a straightforward concept can lead to a highly
addictive game. In creating this game, we explored key
programming concepts, such as event handling, physics-based
motion, collision detection, and score tracking. Through
implementing these features, we learned how to manage real-
time user input to control the bird's movement, calculate
collision boundaries with pipes, and simulate gravity for a
realistic falling effect.
This project not only strengthened our technical skills but also
deepened our understanding of game design principles, like
pacing and difficulty balancing. By carefully adjusting variables
such as the speed of the bird and the spacing of the pipes, we
aimed to find the right balance between challenge and
playability, making the game accessible yet rewarding.
BIBLIOGRAPHY
27
List of sites, docs used for reference:
YouTuber:
https://www.youtube.com/@CodingWithRuss/featured
28