Professional Documents
Culture Documents
COMPUTER Ip
COMPUTER Ip
COMPUTER Ip
ANUPURAM
2023-2024
NAME :
CLASS : XII
SECTION :B
CLASS ROLL NUMBER :
1
CERTIFICATE
INTERNAL
EXAMINER
2
ACKNOWLEDGEMET
Last but not the least I would like to thank all the people who had
helped me directly or indirectly during the completion of this project
and providing me with the much-needed support and motivation.
3
Table of Contents
4
Introduction
❖ About Space invaders Game :-
5
❖ Python Overview:-
6
❖ Features of Python :-
1. Easy :-
Python is a very easy to learn and understand; using this python tutorial,
any beginner can understand the basics of python.
2. Interpreted :-
It is interpreted (executed) line by line. This makes it easy to test and
debug.
3. Object Oriented :-
The python programming language supports classes and objects.
4. Free and Open-Source :-
The language and it’s source code are available to the public for free;
there is no need to buy a costly license.
5. Portable :-
Since it is open source, we can run python on windows, mac, linux, or
any other platforms. Our programs will work without needing to the
changed for every machine.
6. GUI (Graphical User Interface) programming :-
We can use it to develop a GUI (Graphical User Interface). One way to
do this is through „Tkinter‟.
7. Large Library :-
Python provides us with a large standard library. We can use it to
implement a variety of functions without needing to reinvent the wheel
every time. Just pick the code we need and continue. This lets us to
focus on other important tasks.
7
❖ Advantages of Python :-
1. Extensible :-
2. Portable
3. Free & Open-Source
4. Readable
5. Embeddable
6. Improved Productivity
7. Simple and Easy
8. Object Oriented
9. Interpreted
10. Extensive Libraries
8
Objective of the project
The objective of this project is to let the students apply the programming
knowledge into a real-world situation/problem and exposed the students how
programming skills help in developing a good software.
9
Proposed System
The objective is to use gunfire to kill every alien. In other words, don't get
killed so you can strike the invaders back. If the user always has three
lives, the game finishes immediately if the invaders (aliens) touch the
bottom of the screen.
10
Module used and their purposes
a. randint( ):
randint() method in Python returns a random integer value between
the two lower and higher limits (including both limits) provided as
two parameters.
11
Source
Code
12
# importing turtle, math and random python modules
import turtle
import math
import random
# Draw border
border_pen = turtle.Turtle()
border_pen.speed(0)
border_pen.color("white")
border_pen.penup()
border_pen.setposition(-300, -300)
border_pen.pendown()
border_pen.pensize(3)
for side in range(4):
border_pen.fd(600)
border_pen.lt(90)
border_pen.hideturtle()
13
# Create the player turtle
player = turtle.Turtle()
player.shape("player.gif")
player.penup()
player.speed(0)
player.setposition(0, -250)
player.setheading(90)
playerspeed = 15
enemyspeed = 5
bulletspeed = 30
14
# define bullet state
# ready - ready to
fire # fire - bullet is
firing bulletstate =
"ready"
def move_right():
x=
player.xcor()
x += playerspeed
if x > 280:
x = 280
player.setx(x)
def fire_bullet():
# Declare bulletstate as a global if it needs changed
global bulletstate
if bulletstate == "ready":
bulletstate = "fire"
# Move the bullet to the just above the player
x = player.xcor()
y = player.ycor() + 10
bullet.setposition(x, y)
bullet.showturtle()
16
# For collision between enemy and player
def isCollision_enemy_player(t1, t2):
distance = math.sqrt(
math.pow(t1.xcor() - t2.xcor(), 2) + math.pow(t1.ycor() - t2.ycor(), 2)
)
if distance < 30:
return True
else:
return False
for enemy in
enemies: # Move
the enemy x =
enemy.xcor()
x += enemyspeed
enemy.setx(x)
17
# Change enemy direction
enemyspeed *= -1
18
player.hideturtle()
bullet.hideturtle()
for e in enemies:
e.hideturtle()
window.bgpic("end.gif")
break
turtle.done()
19
Output
Screens
20
21
Limitations and Future Scope
❖ Limitations :-
❖ Future Scope :-
22
Requirements
❖ Hardware required :-
❖ Software required :-
23
Bibliography
1. www.wikipedia.com
2. www.geeksforgeeks.org
3. www.google.com
4. Computer Science with Python
by Sumita Arora Class XIIth(Book)
24
Thank You!!
25