0% found this document useful (0 votes)
2 views

class 12 computer project final documentation

This document is about class 12 computer project final documentation

Uploaded by

khatheejatkubra
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)
2 views

class 12 computer project final documentation

This document is about class 12 computer project final documentation

Uploaded by

khatheejatkubra
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/ 28

INDEX

S.NO CONTENTS PAGE


NO

1. ABSTRACT 2

2. FEASABILITY STUDY 3

3. SYSTEM REQUIREMENT 4

4. ERROR AND ITS TYPES 5

5. TESTING 6

6. MAINTANANCE 7

7. MODULES USED 8

8. FLOW CHART 9

9. CODING 10

10. SAMPLE OUTPUT 22

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.

Here’s how it works: The bird automatically moves forward, and


it is constantly pulled downward by gravity, so it will fall unless
the player taps the screen to make it “flap” and rise. Each tap
makes the bird jump slightly upward, allowing players to control
its flight path through the pipes. The game requires careful
timing and quick reflexes, as the pipes are spaced closely
together and appear at different heights.

The simplicity of the controls—just a single tap—makes it easy


to start playing, but the gameplay itself is difficult because
each tap needs precise timing. Just one mistimed flap can
cause the bird to crash. This mix of simplicity and difficulty
makes Flappy Bird very addictive, as players strive to improve
their high scores with each attempt.

Flappy Bird has become popular worldwide because of its


simplicity, challenging nature, and the sense of
accomplishment players feel when they beat their own high
scores.

2
1.FEASIBILITY STUDY

Feasibility study is a system proposal according to its work,


ability, impact on the operation ability to meet the needs of
users and efficient use of resources. An important outcome of
preliminary investigations the determination of that system
requested feasible.

1.1 Economical Feasibility:

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.

1.2 Technical Feasibility:


 Simple user interface
 Login and Signup
 Enjoying with Game
 Saving the Score in a CSV file
 Can Play with User’s High Score
 Can Check Leader Board

2. SYSTEM REQUIREMENTS
3
2.1 MINIMUM:

Processor: Intel Core i3-2330M or (newer or equivalent)


Graphics Card: NVIDIA GeForce 410M
Disk: 100MB Storage
OS: Microsoft Windows 10
RAM: 2GB RAM

2.2 SOFTWARE:
Python (Version 3.11 or newer)

3. ERROR AND ITS TYPES

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

3.1 Compile-time error: Errors that occur during


compilation of a program is called compile times error. It has
two types as follows:

3.1.1 Syntax Error: It refers to formal rules governing


the construction of valid statements in a language.

3.1.2 Semantics Error: It refers to the set of rules


which give the meaning of a statement.

3.2 Runtime Error: Errors that occur during the execution


of program are runtime errors. These are harder to detect
errors. Some runtime errors stop the execution of program
which is the called program “Crashed”.

3.3 Logical Error: Sometimes, even if you don’t encounter


any error during compiling-time and runtime, your program
does not provide the correct result. This is because the
programmer’s mistaken analysis of the problem he/she is trying
to solve. Such errors are called logical errors.

4. TESTING

4.1 Alpha Testing: It is the most common type of testing


used in the software industry. The objective of this testing is to
5
identify all possible issues or defects before releasing it into the
market or to the user. It is conducted at the developer’s site.

4.2 Beta Testing: It is a formal type of software testing


which is carried out by the customers. It is performed in a real
environment before releasing the products into the market for
the actual endusers. It is carried out to ensure that there is no
major failures in the software or product and it satisfies the
business requirement. Beta Testing is successful when the
customer accepts the software.

4.3 White Box Testing: White Box Testing is based on the


knowledge about the internal logic of an application’s code. It is
also known as Glass Box Testing. Internal software and code
working should be known for programming this type of testing.
These tests are based in the coverage of the code statements,
branches, paths, conditions, etc.

4.4 Black Box Testing: It is a software testing method in


which the internal structure or design of the item to be tested is
not known to the tester. This method of testing can be applied
virtually to every level of the software 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:

5.1 Corrective Maintenance: When the program


after compilation shows error because of some unexpected
situations, untested areas such errors are fixed up by
Corrective Maintenance.

5.2 Adaptive Maintenance: Changes in the


environment in which an information system operates may
lead to system management. To accommodate changing
need time to time maintenance is done and is called
Adaptive Maintenance.

5.3 Preventive Maintenance: If possible the errors


could be anticipated before they actually occur; the
maintenance is called Preventive Maintenance.

5.4 Perfective Maintenance: In this rapidly growing


world, information technology is the fastest growing area. If
the existing system is maintained to keep tuned with the
new features, new facilities, new capabilities, it is said to be
Perfective Maintenance.

6.MODULES USED

1. pygame (The Game Toolkit)

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).

2. random (For Making Things Exciting)

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.

3. time (For Pauses or Delays)

If you want to create a short break in the game (like waiting


before restarting after the bird crashes), you'd use the time
module. It can help you pause the game for a second or two
before something happens.

4. sys (For Exiting the Game Cleanly)

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

Store score in database Space bar

Connect to database

Save score Apple gravity to bird


and update bird
Display high score position

Move pipes left


generate new pipes if
needed

Check for collision(pipes


or ground
It is collided with
pipes or ground
Update score if
bird passes pipe
score+=1

Check end of game Collision detected

Continue game Stop


loop

10
SOURCE CODE
import pygame, random, time, csv

from pygame.locals import *

# 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'

hit = '//192.168.25.251/Class 12/12-B2/12B2 24-25/12


B2/S_hawndan_I_el.S/flappy bird/flappy bird audios/hit.wav'

# Initialize mixer

pygame.mixer.init()

# Helper function to read high score from CSV

def read_highscore():

try:

with open(CSV_FILE, mode='r') as file:

reader = csv.reader(file)

for row in reader:

return int(row[0])

except FileNotFoundError:

return 0

# Helper function to write high score to CSV

def write_highscore(score):

with open(CSV_FILE, mode='w', newline='') as file:

writer = csv.writer(file)

12
writer.writerow([score])

# Initialize high 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):

def __init__(self, inverted, xpos, ysize):

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:

self.image = pygame.transform.flip(self.image, False,


True)

self.rect[1] = -(self.rect[3] - ysize)

else:

self.rect[1] = SCREEN_HEIGHT - ysize

self.mask = pygame.mask.from_surface(self.image)

def update(self):

self.rect[0] -= GAME_SPEED

class Ground(pygame.sprite.Sprite):

def __init__(self, xpos):

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

self.rect[1] = SCREEN_HEIGHT - GROUND_HEIGHT

def update(self):

self.rect[0] -= GAME_SPEED

def is_off_screen(sprite):

return sprite.rect[0] < -(sprite.rect[2])

def get_random_pipes(xpos):

size = random.randint(100, 300)

pipe = Pipe(False, xpos, size)

pipe_inverted = Pipe(True, xpos, SCREEN_HEIGHT - size -


PIPE_GAP)

return pipe, pipe_inverted

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):

pipes = get_random_pipes(SCREEN_WIDHT * i + 800)

pipe_group.add(pipes[0])

pipe_group.add(pipes[1])

clock = pygame.time.Clock()

begin = True

while begin:

clock.tick(15)

for event in pygame.event.get():

if event.type == QUIT:

pygame.quit()

if event.type == KEYDOWN:

if event.key == K_SPACE or event.key == K_UP:

bird.bump()

pygame.mixer.music.load(wing)

pygame.mixer.music.play()

begin = False

18
screen.blit(BACKGROUND, (0, 0))

screen.blit(BEGIN_IMAGE, (120, 150))

if is_off_screen(ground_group.sprites()[0]):

ground_group.remove(ground_group.sprites()[0])

new_ground = Ground(GROUND_WIDHT - 20)

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)

for event in pygame.event.get():

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()

screen.blit(BACKGROUND, (0, 0))

current_score += 1 # Increment score as the game


progresses

if is_off_screen(ground_group.sprites()[0]):

ground_group.remove(ground_group.sprites()[0])

new_ground = Ground(GROUND_WIDHT - 20)

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)

# Check and update high score

if current_score > high_score:

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.

In terms of educational value, building Flappy Bird provided


insights into the iterative nature of game development, where
testing and tweaking are essential for achieving the desired
player experience. Additionally, this project opened up avenues
for exploring more advanced game elements in the future, such
as power-ups, levels, and enhanced graphics. Overall, the
Flappy Bird game serves as a testament to how simple
gameplay mechanics, when executed well, can offer a fun and
memorable experience for players, highlighting the creative
potential in game development.

BIBLIOGRAPHY

27
List of sites, docs used for reference:
 YouTuber:
https://www.youtube.com/@CodingWithRuss/featured

List of book, docs used for reference:

 Computer Science with python(class 12)(SUMITA ARORA)

28

You might also like