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

Final Project Report Format - Class 11

The document is a project report for a space invader game created by Arya Arora and Shashank Kumar, students of Class XI D at Sardar Patel Vidyalaya in New Delhi, India. It was created under the guidance of their computer science teacher, Ms. Angel Panesar. The report describes the libraries and modules used to create the game, including pygame, sys, math, random, and os. It also includes the project code, output screenshots, and conclusions.

Uploaded by

shashank kumar
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)
76 views

Final Project Report Format - Class 11

The document is a project report for a space invader game created by Arya Arora and Shashank Kumar, students of Class XI D at Sardar Patel Vidyalaya in New Delhi, India. It was created under the guidance of their computer science teacher, Ms. Angel Panesar. The report describes the libraries and modules used to create the game, including pygame, sys, math, random, and os. It also includes the project code, output screenshots, and conclusions.

Uploaded by

shashank kumar
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/ 15

Project Report

on
Space Invader

Submitted By
ARYA ARORA
SHASHANK KUMAR
Class: XI D

Under the Guidance of


Ms. Angel Panesar
Department of Computer Science
Sardar Patel Vidyalaya
Lodhi Estate, New Delhi 110003
CERTIFICATE
This is to certify that SHAHANK KUMAR and ARYA ARORA Of
Class XI D have prepared the report on the Project entitled “space
invader”. The report is the result of their efforts & endeavors. The report
is found worthy of acceptance as final project report for the subject
Computer Science of Class XI. They have prepared the report under my
guidance.

Ms. Angel Panesar


Department of Computer Science
Sardar Patel Vidyalaya
Lodhi Estate, New Delhi 110003
DECLARATION
We hereby declare that the project work entitled “space invader”,
submitted to Department of Computer Science, Sardar Patel Vidyalaya,
Lodhi Estate, New Delhi 110003 is prepared by us. The project work is
result of our personal efforts.

SHASHANK KUMAR
ARYA ARORA
Class: XI D
ACKNOWLEDGEMENT
I would like to express my special thanks of gratitude to my computer
science teacher Ms. Angel Panesar for her able guidance and support in
completing our project.

ARYA ARORA
SHASHANK KUMAR
Class: XI D
CONTENTS
S. No. Topic Page No.
1. LIBRARIES USED 1-1
2. WORKING 2-4
DESCRIPTION
3. PROJECT CODE 5-7
4. OUTPUT SCREENS 7-8
5. CONCLUSION 9-9
6. BIBLIOGRAPHY 10-10
LIBRARIES USED

Following are the librarie which where used during the project where
1. pygame

WORKING DESCRIPTION
The various modules which were used in my program are:-
1. sys module(System – specific parameters and functions)
2. maths module
3. random module
4. os module.

1.SYS MODULE(system specific relation and function)


Python sys module provides easy functions that allow us to interact with the
interpreter directly.
The functions python sys module provides allows us to operate on underlying
interpreter, irrespective of it being a Windows Platform, Macintosh or Linux. In
this lesson, we will review these functions and what we can do with these.

2. MATH MODULE
Python’s standard library provide a module namely math for mat related
function that work with all number types expect for complex numbers.
In order to use math module in python we firstly import the math module by
using import function .
Inside math module we have many functions for example
Ceil function ,sqrt function , exp function , fabs function, floor function, log
function, log 10, pow , sin, tan, cos , degrees, radians

3. RANDOM MODULE
Python offers random module that can generate random numbers.

These are pseudo-random number as the sequence of number generated depends on


the seed.

If the seeding value is same, the sequence will be the same. For example, if you use 2
as the seeding value, you will always see the following sequence.
4. OS MODULE
The os module in python provides a way of using operating system dependent
functionality
The functions that the os module allow you to interface with the underling
operating system on which the python is running on be that the windows mac or
linux
You can find important information about your location or about the proess

The different types of functions inside the os module are


1.os.system
2.os.environ
3.os.getcwd
4.os.getgid
5.os.getaid
6.os.getaid
7.os.getpid
PROJECT CODE
from stuff import*

size = (800, 600)


screen = pygame.display.set_mode(size, 32)
ship = Ship(size)
shot_L = []
explosion_L = []
enemy_L = []
enemyshot_L = []
star_L = []

boom_s = pygame.mixer.Sound("boom.wav")
shot_s = pygame.mixer.Sound("shot.wav")
highscore_s = pygame.mixer.Sound("highscore.wav")

wait = 0
time=0

gameover = pygame.image.load("gameover.gif")

gameover_r = gameover.get_rect()
gameover_r = gameover_r.move([size[0]/2-gameover_r.width/2, size[1]/2-
gameover_r.height/2])
score = 0

pygame.mouse.set_visible(False)

song = pygame.mixer.Sound("technotris.wav")
song.play(-1)

for star in xrange(100):


star_L.append(Star(size))

################## START #################

while 1:
time+=1
keys = pygame.key.get_pressed()

#restarts when you die and then press enter


if ship==None and keys[K_RETURN]:
song.play(-1)
score=0
ship=Ship(size)
wait = 0
time=1
shot_L = []
explosion_L = []
enemy_L = []

#checks if the ship should be shooting


if keys[K_SPACE] and not wait and ship!=None:
shot_L.append(Shot(ship.rect.center, 'right'))
shot_s.play()
wait=True

if not keys[K_SPACE]: wait = False

#creates a new alien


if time%(1000000/(score+1)+1)==0:
if random.randint(0,1)==0:
enemy_L.append(Enemy2(list((size[0]+100,random.randint(50,size[1]-50))),
enemyshot_L))
elif random.randint(0,1)==0:
enemy_L.append(Enemy3(list((size[0]+100,random.randint(50,size[1]-50)))))
else: enemy_L.append(Enemy1([size[0]+100,random.randint(50,size[1]-50)]))
if time%100==0: enemy_L.append(Enemy1([size[0]+100,random.randint(50,size[1]-
50)]))

#updates the shots


for shot in shot_L:
shot.update(screen)
if shot.rect[0]>size[0]:
shot_L.remove(shot)
#updates the explosions
for boom in explosion_L:
boom.update(screen)
if boom.life<=0:
explosion_L.remove(boom)

#updates the enemys


for enemy in enemy_L:

enemy.update(screen, time, ship)

#blows up the ship if it runs into a alien


if ship!=None and enemy.rect.colliderect(ship.rect) :
pygame.time.wait(50)
screen.fill([255,0,0])

info = open("highscore.spacegame","r")
highscore = int(info.readline())

if score-1>highscore:
highscore_s.play()
info = open("highscore.spacegame","w")
info.write(str(score))

explosion_L.append(Explosion(ship_pos))
ship = None
enemy_L.remove(enemy)
boom_s.play()

# deletes an enemy once it's left the screen


if enemy.rect.left<-50:
enemy_L.remove(enemy)
if ship!=None: score-=25

#checks if the alien has been shot


for shot in shot_L:
if shot.rect.colliderect(enemy.rect):
explosion_L.append(Explosion(enemy.rect.center))
boom_s.play()
try:
enemy_L.remove(enemy)
except:
pass
shot_L.remove(shot)

if ship!=None: score+=100

#decides if the ship has been blow up, then updates


if ship !=None:
ship.update(screen,keys,size)
ship_pos = ship.rect.topleft
else:
screen.blit(gameover, gameover_r)
song.stop()
#updates stars
for star in star_L:
star.update(screen)

#updates enemy's shots, checks if it hit the ship


for shot in enemyshot_L:
shot.update(screen)
if ship!= None and shot.rect.colliderect(ship.rect):
enemyshot_L.remove(shot)
explosion_L.append(Explosion(ship_pos))
ship = None
boom_s.play()

#scoring system
score = max(0, score)

score_t = pygame.font.SysFont("arial", 20).render('score - '+str(score), False,


(255,255,255))
score_t_r = score_t.get_rect()
score_t_r = score_t_r.move([size[0]/2-score_t_r.width/2, size[1]-size[1]/10])

screen.blit(score_t, score_t_r)

#updates the screen


pygame.display.flip()
screen.fill([0,0,0])

# === ANTI-CRASH ===


for event in pygame.event.get():
if event.type == QUIT or keys[K_ESCAPE]:
pygame.quit(); sys.exit()

OUTPUT SCREENS
1. Enemy number one

2. Enemy number two

3. Enemy number three

4. In between illustrations

5. Battle spaceship

6.Final output

Final screenshot of module


CONCLUSION
This project helped us in having a better understanding of libraries such as pygame
and many modules of python .It was surely a very knowledgeable experience and
we would surely want to do this in future too.
BIBLIOGRAPHY

1. Sumita Arora, Computer Science with Python, 2019


2.https://www.youtube.com/channel/UCirP

You might also like