0% found this document useful (0 votes)
36 views31 pages

Wa0000.

Uploaded by

Jatin Choudhary
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)
36 views31 pages

Wa0000.

Uploaded by

Jatin Choudhary
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/ 31

Internship Assessment/Mini Project Report

Submitted

in Partial Fulfillment of the Requirements

For the Degree of

Bachelor of Technology

In

Computer Science and Engineering

By

Divyansh Sharma
2100040100024
Year: 2nd

Department of Computer Science & Engineering

F. E. T., R. B. S. Engineering Technical Campus, Bichpuri,

Agra (U.P.)
Table of Contents

Topic Page No.


 DECLERATION

 CERTIFICATE

 ACKNOWLEDGEMENT

 ABSTRACT

1.0 INTRODUCTION
1.1 Introduction
1.2 Objective
1.3 Scope

2.0 MINIMUM HARDWARE AND SOFTWARE REQUIREMENT


3.0 MATERIALS AND METHODS
3.1 Project Category
3.2 Techniques to be used
3.2.1 Python
3.2.2 Pygame
3.3 Parallel Techniques Available
3.3.1 Visual Studio Code

4.0 WORKFLOW AND METHODOLOGY


5.0 LIMITATIONS AND DELIMITATIONS
6.0 CONCLUSION
7.0 REFERENCES
DECLARATION

I declare that the project work presented in this Internship Assessment Titled: “Space War

Game” submitted to the Computer Science and Engineering Department, Raja Balwant Singh

Engineering Technical Campus, Bichpuri, Agra, or the award of the Bachelor of Technology

degree in Computer Science & Engineering is my original work.

All the work is accomplished by me and I have not plagiarized or submitted the same work for

the award of any other degree.

21 December, 2022

Agra
CERTIFICATION
ACKNOWLEDGEMENT

I have taken efforts in this project report. However, it would not have been possible without the

kind support and help of many individuals and organizations. I would like to extend my sincere

thanks to all of them.

I am highly indebted to Dr. Ashok Kumar for his guidance and constant supervision as well as

for providing necessary information regarding the project and also for his support in completing

the project.

I would like to express my gratitude towards my parents and members of our faculty for their

kind co-operation and encouragement which helped me in completion of this project. My thanks

and appreciation also goes to my colleagues in developing the project who have willingly helped

me out with their abilities.


Abstract

Description:-
Space war is the classic arcade game which released first in year 1987 at Japan. Since then the
game has released several times in multiple themes and game settings. However the main idea
behind the game is same which is as follows.

The game deals with two kinds of spaceships: Enemy spaceships of same appearance and one
unique spaceship which represent the player spaceship. The player spaceship move horizontally
at the bottom of the screen and the enemy spaceships perform random motion at upper side of the
game window towards the bottom. The player spaceship has to shoot the enemy spaceships. If
any of the enemy spaceships reaches at the bottom, the game ends.

Software Requirements:-
The game is developed by using the standard gaming library of Python named as “Pygame”. The
Pygame library allows users to create the gaming environment they want and the specific set to
operate the game.

In code editor, ‘Visual Studio Code’ has been used in this project which is an highly scalable
Integrated Develop Environment. Visual Studio Code was developed by Microsoft which
facilitates the user to write and run the code of any language.

In addition of it, two built-in modules of python language (random and math) have been used for
certain logics of game.

Features:-
➢ There is a score section in the game. One point awards to player for destroying each enemy
spaceship.

➢ Real Time Sound Effects has added into the game. When the player shoots or the bullet hits
the enemy spaceship, different sound produces.
Chapter 1
Introduction

1.1 Introduction
Space War, arcade game created by Japanese engineer and game designer Nishikado
Tomohiro in 1978 and produced by Japanese electronic game manufacturer Taito Corp.

The objective of ‘Space War’, which was one of the earliest video games released, is to pan
across a screen and shoot descending swarms of enemy ships, preventing them from reaching
the bottom of the screen. It is viewed as a pioneer of modern gaming.

(The Original Space War Theme of Nishikado)

Space War is a fixed shooter in which the player moves horizontally across the bottom of the
screen and fires at enemy ships overhead. The enemy ships begin as 6 in total, left and right as a
group, shifting downward each time they reach a screen edge. The goal is to shoot as many
enemy ships as possible.
The game ends immediately if the invaders reach the bottom of the screen. As enemy ships are
shoot out and defeated, a sound of hit produces each time and the score running on the upper left
corner of the display increases by 1. Shooting the enemy ships brings other enemy ships into war
which starts lower, a loop which can continue endlessly.

Space War was a worldwide success and paved the way for a generation of shooting games that
became extremely popular. In Japan demand for the arcade game was so great that it led to a coin
shortage and prompted an increase in production of the 100-yen coin.

1.2 Objective
The main objective of this project is to develop a 2D game. As it sounds, it is purposely used to
create an entertainment game for fun in programming.

Originally, at when Nishikado developed this game, there were need to install special hardware
to play it. Such hardware wasn’t affordable by everyone so many people were used to play it by
paying in Game Houses, since when it gained popularity.

As time passed, the gaming world began to take its modern form. Several consoles and gaming
stations became available in market so the game wasn’t out of hands by anybody who is
interested in gaming.

In programming world, Python appeared as a powerful language in the era of 90’s, which was
written in other languages like C, FORTRON, but it created a revolution in programming era and
begins to take place of other languages. Python is object-oriented programming language which
first became available with many built in libraries. During the time, other libraries like Tensor
flow, Pygame, Open CV began to collaboration with Python, and could easily implemented in
Python Programs.

Now, it wasn’t difficult to develop any application. Such collaboration in Python increased its
popularity among developers and the games for which there was need to install special hardware,
now someone could play them in their modern computers by code the game in Python.
We are going to use this 2D game programming in this game.

The other objective to implement this game was actually using the 2D gaming concepts included
with Python. This shows how useful Python is as compare to other languages. Such 2D games
can be easily designed and functionalize by using the GUI libraries of Python.

1.3 Scope
The scope of the game is divided widely into different sections.

If we discuss about who can play it or for which class of players, the game is useful, so there isn’t
any restriction in it. Not only the gamers, but also it’s quite easy and fun game for the kids and
people who want to get refresh by stressing work or a light enjoy.

However, it’s truly based on the screen time so it shouldn’t be play for hours but to make mood
better or spend time, the game can be played.

Another thing is that, anyone can edit the code regarding to change the elements of the game, so
it’s quite interesting to play by our own chosen ships, backgrounds and bullets.

There isn’t any need of Internet so obviously, the game doesn’t contain any personal information
or which can be hacked, so the security system of the game is good in some way, and either it’s
just an offline game, so the question of security doesn’t arise even.

So, The Scope is divided among these described ways and the game can be quite useful to make
mood refresh instead of being on social media and filling up mind with negative things. Good
games bring positive energy in our life, so all games aren’t the trash of time, but some make our
life way easier in indirect way also.
Chapter 2
Minimum Hardware and Software Requirement

2.1 Hardware Requirements

Operating system : 32/64/128 bit Operating System

Processor : Intel(R) Core(TM) i3 CPU 5+ generation

RAM: At least 6 GB RAM

Connectivity: No internet connection needed

External Devices Needed : None

2.1 Software Requirements

Integrated Development Environment : Visual Studio Code


Chapter 3
Materials and Methods

3.1 Project Category


The project belongs to the category of 2D game-development about which we have discusses
some in chapter 1 but here we will discuss its parent branch which is the Video Game
Programming.

Generally, as name suggest the video game programming deals with the development and testing
of games by using programming as the tool. After the development, when the game is ready for
production build, it can be host by using any hosting service available in market.

First thing first, let’s go through over video game programming.

Video Game Programming:


Game programming, a subset of game development, is the software development of video
games. Game programming requires substantial skill in software engineering and computer
programming in a given language, as well as specialization in one or more of the following
areas: simulation, computer graphics, artificial intelligence, physics, audio programming,
and input. For multiplayer games, knowledge of network programming is required (the resultant
code, in addition to its performance characteristics, is commonly referred to as the game's net
code by players and programmers alike). In some genres, e.g. fighting games, advanced network
programming is often demanded, as the net code and its properties (e.g. latency) are considered
by players and critics to be some of the most important metrics of the game's quality.
For massively multiplayer online games (MMOGs), even further knowledge of database
programming and advanced networking programming are required. Though often engaged in by
professional game programmers, there is a thriving scene of independent developers who lack a
relationship with a publishing company.

Like other software, game development programs are generated from source code to the actual
program (called the executable) by a compiler.
Source code can be developed with almost any text editor, but many professional game
programmers use a full integrated development environment. Once again, which IDE one uses
depends on the target platform.

In addition to IDEs, many game development companies create custom tools developed to be


used in-house. Some of these include prototypes and asset conversion tools (programs that
change artwork, for example, into the game's custom format). Some custom tools may even be
delivered with the game, such as a level editor.

Game development companies are often very willing to spend thousands of dollars to make sure
their programmers are well equipped with the best tools. A well outfitted programmer may have
two to three development systems and multiple monitors dominating their office or cubicle.

API’s and Libraries:


A key decision in game programming is which, if any, APIs and libraries to use. Today, there are
numerous libraries available which take care of key tasks of game programming. Some libraries
can handle sound processing, input, and graphics rendering. Some can even handle some AI tasks
such as path finding. There are even entire game engines that handle most of the tasks of game
programming and only require coding game logic.

Which APIs and libraries one chooses depends largely on the target platform. For example,
libraries for PlayStation 2 development may not be available for Microsoft Windows and vice
versa. However, there are game frameworks available that allow or ease cross-platform
development, so programmers can program a game in a single language and have the game run
on several platforms, such as the Wii, PlayStation 3, Xbox 360, PSP and Microsoft Windows.
3.2 Techniques to be used

This section deals with the technologies used to build this game.

As the purpose of programming, I’ve used Python Language to write all the functionalities and
logics of the game. Python is a general purpose programming language which is dynamic, open
source and highly scalable. The Python Programming Language provides a vast set of libraries
which are themselves rich in various modules to generate much functionality (i.e. GUI Interface).

To develop the GUI interface, I’ve used Pygame which is a gaming library of Python and
facilitate the user to build 2-D games of the desired functionalities and logics. Pygame library is
the combinational form which has many modules inside it. The Programming in Pygame is much
easy as compare to the other GUI libraries of Python (like Tkinter, PyQT5).

In this chapter, we are about to see detail explanation about Python and Pygame.

3.2.1 Python

Python is a very popular general-purpose interpreted, interactive,


object-oriented, and high-level programming language. Python is
dynamically-typed and garbage-collected programming language.

It was created by Guido van Rossum during 1985- 1990. Like Perl,
Python source code is also available under the GNU General Public
License (GPL).

Python is consistently rated as one of the world's most popular programming languages. Python
is fairly easy to learn and implement. Today various Schools, Colleges and Universities are
teaching Python as their primary programming language.

There are many other good reasons which make Python as the top choice of any programmer:

 Python is Open Source which means it’s available free of cost.


 Python is simple and so easy to learn
 Python is versatile and can be used to create many different things.

 Python has powerful development libraries include AI, ML etc.


 Python is much in demand and ensures high salary.

Python is a MUST for students and working professionals to become a great Software
Engineer especially when they are working in Web Development or Data Science Domain.

Key Features of Python:


 Python is Interpreted − Python is processed at runtime by the interpreter. You do
not need to compile your program before executing it. This is similar to PERL and
PHP.
 Python is Interactive − you can actually sit at a Python prompt and interact with
the interpreter directly to write your programs.
 Python is Object-Oriented − Python supports Object-Oriented style or technique
of programming that encapsulates code within objects.
 Python is a Beginner's Language − Python is a great language for the beginner-
level programmers and supports the development of a wide range of applications from
simple text processing to WWW browsers to games.

Characteristics of Python:
Following are important characteristics of Python Programming −
 It supports functional and structured programming methods as well as OOP.

 It can be used as a scripting language or can be compiled to byte-code for building

large applications.

 It provides very high-level dynamic data types and supports dynamic type checking.

 It supports automatic garbage collection.

 It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.

Applications of Python:
 Easy-to-learn − Python has few keywords, simple structure, and a clearly defined
syntax. This allows the student to pick up the language quickly.
 Easy-to-read − Python code is more clearly defined and visible to the eyes.
 Easy-to-maintain − Python's source code is fairly easy-to-maintain.
 A broad standard library − Python's bulk of the library is very portable and
cross-platform compatible on UNIX, Windows, and Macintosh.
 Interactive Mode − Python has support for an interactive mode which allows
interactive testing and debugging of snippets of code.
 Portable − Python can run on a wide variety of hardware platforms and has the same
interface on all platforms.
 Extendable − You can add low-level modules to the Python interpreter. These
modules enable programmers to add to or customize their tools to be more efficient.
 Databases − Python provides interfaces to all major commercial databases.
 GUI Programming − Python supports GUI applications that can be created and
ported to many system calls, libraries and windows systems, such as Windows MFC,
Macintosh, and the X Window system of Unix.
 Scalable − Python provides a better structure and support for large programs than
shell scripting.

3.2.2 Pygame
Game programming is very rewarding nowadays and it can also be used in advertising and as a
teaching tool too. Game development includes mathematics, logic, physics, AI, and much more
and it can be amazingly fun. In python, game programming is done in Pygame and it is one of the
best modules for doing so.

Pygame is a cross-platform set of Python modules designed for writing video games. It


includes computer graphics and sound libraries designed to be used with the
Python programming language.

History:
Pygame was originally written by Pete Shinners to replace PySDL after its development stalled.
It has been a community project since 2000 and is released under the free software GNU Lesser
General Public License (which "provides for Pygame to be distributed with open source and
commercial software").
Pygame version 2 was planned as "Pygame Reloaded" in 2009, but development and
maintenance of Pygame completely stopped until the end of 2016 with version 1.9.1. After the
release of version 1.9.5 in March 2019, development of a new version 2 is active on the roadmap.

Features:
Pygame uses the Simple Direct Media Layer (SDL) library, with the intention of allowing real-
time computer game development without the low-level mechanics of the C programming
language and its derivatives. This is based on the assumption that the most expensive functions
inside games can be abstracted from the game logic, making it possible to use a high-level
programming language, such as Python, to structure the game.

Other features that SDL does have include vector math, collision detection, 2D sprite scene
graph management, MIDI support, camera, pixel-array manipulation, transformations, filtering,
advanced free type font support, and drawing.

Applications using Pygame can run on Android phones and tablets with the use of Pygame
Subset for Android (pgs4a).  Sound, vibration, keyboard, and accelerometer are supported on
Android.

Installation and Set Up:


To use Pygame in your Python Project, first we need to install the Pygame Library and then set
up the process.

 To install the Pygame, first open the Command Prompt or Windows PowerShell in your
system and then use pip Command.
 Write “pip install pygame” on prompt and run the command.

 All the necessary libraries and modules inside Pygame will be installing.
 To tell the interpreter that you’re about to use a non-built library in your program, we use
“import” keyword.
 For importing Pygame, we have to write “import pygame” in the most beginning of our
Python code.
 After importing Pygame, we need to initialize all the Pygame modules by using line
“pygame.init()”

3.3 Parallel Techniques available


To writing the python code, there are many popular IDE’s including python shell like Sublime
text, Atom, PyCharm but in this project, I’ve used Visual Studio Code since it’s an open source
platform which provides many features which makes writing code fast and readability increases.

3.3.1 Visual Studio Code


Visual Studio Code, also commonly referred to as VS Code, is a source-code editor made
by Microsoft with the Electron Framework, for Windows, Linux and macOS. Features include
support for debugging, syntax highlighting, intelligent code completion, snippets, code
refactoring, and embedded Git. Users can change the theme, keyboard shortcuts, preferences, and
install extensions that add additional functionality.

In the Stack Overflow 2021 Developer Survey, Visual Studio Code was ranked the most popular
developer environment tool among 82,000 respondents, with 70% reporting that they use it.

2.3.1 History
Visual Studio Code was first announced on April 29, 2015, by Microsoft at the
2015 Build conference. A preview build was released shortly thereafter.
On November 18, 2015, the source of Visual Studio Code was released under the MIT License,
and made available on GitHub. Extension support was also announced.

On April 14, 2016, Visual Studio Code graduated from the public preview stage and was released
to the Web.  Microsoft has released most of Visual Studio Code's source code on GitHub under
the permissive MIT License, while the releases by Microsoft are proprietary freeware.

2.3.2 Features
Visual Studio Code is a source-code editor that can be used with a variety of programming
languages including C#, Java, JavaScript, Go, Node.js, Python, C++, C, Rust and Fortran. It is
based on the Electron framework, which is used to develop Node.js web applications that run on
the Blink layout engine. Visual Studio Code employs the same editor component (codenamed
"Monaco") used in Azure DevOps (formerly called Visual Studio Online and Visual Studio
Team Services).

Out of the box, Visual Studio Code includes basic support for most common programming
languages. This basic support includes syntax highlighting, bracket matching, code folding, and
configurable snippets. Visual Studio Code also ships with IntelliSense for JavaScript,
TypeScript, JSON, CSS, and HTML, as well as debugging support for Node.js. Support for
additional languages can be provided by freely available extensions on the VS Code
Marketplace.

Instead of a project system, it allows users to open one or more directories, which can then be
saved in workspaces for future reuse. This allows it to operate as a language-agnostic code editor
for any language. It supports many programming languages and a set of features that differs per
language. Unwanted files and folders can be excluded from the project tree via the settings.
Many Visual Studio Code features are not exposed through menus or the user interface but can
be accessed via the command palette.

Visual Studio Code can be extended via extensions, available through a central repository. This
includes additions to the editor and language support.
A notable feature is the ability to create extensions that add support for new languages, themes,
debuggers, time travel debuggers, perform static code analysis, and add code linters using the
Language Server Protocol.

(Popularities of IDEs among Developers in 2022)

Source control is a built-in feature of Visual Studio Code. It has a dedicated tab inside of the
menu bar where users can access version control settings and view changes made to the current
project. To use the feature, Visual Studio Code must be linked to any supported version control
system (Git, Apache Subversion, Perforce, etc.).

This allows users to create repositories as well as to make push and pull requests directly from
the Visual Studio Code program. Visual Studio Code includes multiple extensions for FTP,
allowing the software to be used as a free alternative for web development. Code can be synced
between the editor and the server, without downloading any extra software.

Visual Studio Code allows users to set the code page in which the active document is saved, the
newline character, and the programming language of the active document. This allows it to be
used on any platform, in any locale, and for any given programming language (promotional
language) Visual Studio Code collects usage data and sends it to Microsoft, although this can be
disabled.

Due to the open-source nature of the application, the telemetry code is accessible to the public,
who can see exactly what is collected.
Chapter 4
Workflow and Methodology

In last chapter, we discussed about the technology used in this game projects, which includes
programming-language, integrated development environment and so on.

In this chapter, we will see the methods used in the code project (i.e. user defined functions) and
the flow/order of those several functions.

In the sub-section “Pygame” of previous chapter which is the main technology used for the
project, we have seen the installation process and Python setup for our project so now begin by
the context of code and library installation for code particularly.

The main headings of methodology are following:

 Initialization of Library
Before starting the project, we first need to install the library “Pygame” in our code file.

In python, this thing is done by using import statements.

 We have to write, “import pygame” in the first line of our code which import the pygame
library for particular use of our program.
 Next, we will use same procedure to import the random module which is a built in
module of python, used to make random assumes by the python interpreter.
 After, we use .init( ) method of pygame which is generally used to activate all the
methods of the library. Its best practice to initialize the library, since many methods can’t
be run during execution otherwise.
 At last of this section, we will import mixer module separately which is included in
mixer. The use of this sub-module is to access and deal with sound and audio uses within
the program.

 Setting up GUI Display


After installation and initialization of our main program, we need to set up our main screen.
Following, can be achieved easily by the display method of pygame.

The display method of pygame takes two arguments, first one is width and second one is height
(in pixels). It takes a tuple of arguments.

The main code line of setting up GUI display is as follows:

pygame.display.set_mode((width,
pygame.display.set_mode ((width, height))
height))

 Loading Assets
Now, we need to import the game objects which we are about to use in our project.

Precisely, we need two types of files: 1) Image File (.png)

2) Audio File (.wav)

1) We need a background image, one image for the player space-ship and several other different
space-ships represented by target enemies.

The image.load ( ) method of pygame are used to import the image files for use. It takes only one
argument which is the file name of our image assets. The resolution of the image file defines by
the original size measured in pixels and used directly in the Pygame Display. So, to keep manage
the image resolution, it’s essential to resize the image before using it.

The method work as follows:

pygame.image.load (“file_name.png”)

2) We need two audio sounds, one for shooting the bullets, and other one to detect the collision
of bullets with enemy space-ships.

For this purpose, we use the mixer.Sound ( ) method to load the audio filed for mentioned
purpose. The purpose can be achieved by using the following line of code:

Pygame.mixer.Sound (“file_name.wav)
It needs to copy all the images files in the program by using .blit( ) method which we do in the
game loop (described in the next sections). It copy all the loaded images in the GUI display by
each .update ( ) method run.

 Position and Movement


In this section, we will be discussing about the positions of all gaming objects including
background (except the score and game over element since they will discuss separately in their
particular section).

We will discuss both position and movements of each object separately here in several sections.

For Background Image:

Background Image is the static object of our game which will be stationery throughout the game
loop. We have positioned it by using the blit method of pygame.

Since pygame allow the position scale from the top-left corner of the object element so we have
use co-ordinates (0, 0) for desired position and keep the height and width of same as the
particular dimensions of our display, to avoid the unwanted errors of overflow and background
image repetition in display.

For Player Image:

Initially, we have kept our player image static in the beginning on the co-ordinates of (370, 480)
so the object of player would appear in the bottom center having some margin with game display.
The movement of the player space-ship is directly connected to the key event / user controls.

For this purpose, we have constant the FPS (Frame Per Second) to 10 so the key event wouldn’t
create abnormal change in the position of player image object.

So, generally, there isn’t any specific method for movement in pygame but we can accomplish
this problem by making the change in co-ordinates of our objects. So, we have used this strategy
to create movements in our program.
For either case of vertical motion, we haven’t implemented any method for motion, because our
player will only move on the horizontal axis of our program. So, to implement the horizontal
motion, we have used following strategies:

 When the user will press left arrow key (i.e. gives the direction of left), the X co-ordinate
of the player object will decreased by 5 pixels, which would appear as a left-side motion.
 When the user will press right arrow key (i.e. gives the direction of right), the X co-
ordinate of the player object will increased by 5 pixels, which would appear as a right-side
motion.

Another thing to paying attention is that, we have limited the horizontal motion of the player
within the width of the display screen, since player can’t go out of the screen obviously. For this
logic, we have assign the False return value to movement function if the X co-ordinates of player
becomes less left-portion of display or more than right-portion of the display.

For Enemy Image:

For position and movement of enemies, we have used arrays to keep the record of their positions,
amount, positions and change in positions. Since in any game, the, appearance of enemies
(usually targets) is so random and instantly, so we will use the random module of python to point
out the positions of enemies, however we will keep their speed same which is the most common
practice of any arcade shooting game.

Firstly, we will begin a for loop to the amount of enemies space-ships we want to see once at a
time. In our project, we have limited this position to 6. To harden the level, we can also increase
this number.

In this loop block, we will append the enemy spaceship objects at any position above the
horizontal middle of the screen display, so they don’t collide with the player just after
appearance. For this purpose we have used the randint() function of random module up to
the certain ranges.

We also have assigned the positional change in their X and Y co-ordinates by 4 and 40 pixels
respectively. The enemy motion is random that’s why user can’t control over it, however we
have defined a logic that whenever the enemy object will collide to the left and right portions of
the screen, it will move downward by 40 pixels accordingly, to reach towards the player and
fulfill the game over condition.

For Bullet Image:


Bullet motion is probably the most interesting of our game. The implementation of bullet way is
too similar with the enemy-ship motion however; still there are several other things which make
them different which we will discuss in this particular section.

Initially, we have keep the bullet object hidden since the bullet shoot event will occur only after
if the user will give command by key press.

In beginning, we have defined the position of bullet by the co-ordinates of (0, 480) so that the
bullet will appeared and moving from the upper tip of player-ship, so we don’t have to deal with
the horizontal motion of bullet and the logic is build for the upwards motion of bullet because the
enemy space-ship will be moving above to downwards, also we have defined a bullet_state
variable which will activate with the value of “ready” whenever user will give the instruction of
bullet shoot to the player-ship (by pressing SPACE key). In this condition, the fire_bullet function
will execute.

When this function will execute, the X and Y co-ordinates of the bullet object will increase by 16
pixels, which would lead to upwards motion of the bullet.

 Key Events
Key Events are basically just the instructions passed to interpreter when user presses any key of
keyboard. Such thing is used to control the game functionalities.

Pygame allows user to use Mouse Events and Key Board Events for projects. Here, we have used
only Key Board events.

Key Board Events:

There are 2 types of key events in pygame: KEYPRESS and KEYDOWN

KEYPRESS event is used for the events when any movement is represented by the long press of
keys. Such movement is generally in racing games or adventurous walkthrough…

KEYDOWN event is used for the events when any movement is represented by the instant press
of keys. The movement is generally little by little, so need to press keys again and again.

Such type of movements is generally used in Shooting Arcade and Mission Games. In this
project, we will use this type of motion.
.K_LEFT, K_RIGHT, K_SPACE, K_W/A/S/D are some generally used key events for this.

pygame.K_LEFT: This key event would move the player space-ship into left direction.

pygame.K_RIGHT: This key event would move the player space-ship into right direction.

pygame.K_SPACE: This key event would let the player space-ship to fire the bullet upwards.

W/A/S/D keys are also so common in the 2 Dimensional motion of the object but since here we
have to move the player only horizontally, so arrow keys are more appropriate. However, A and
D keys could be used also separately.

 Collision Detection
The particular section has been divided into 2 parts. The first part describes the condition of
collision event and the later part describes the effects shown onto the display after collision
event.

First Part:

Collision condition is the condition which is to check if the bullet has hit the enemy space-ship or
not. The condition is implemented by user defined function in this project.

 So, since the collision will happen here between the enemy and bullet so for successfully
implement this function, we need 4 parameters. Two for X and Y co-ordinates for enemy
space-ship object and the same coordinates for the bullet object.
 We have used the distance formula of Cartesian geometry for this purpose since we know
the X and Y co-ordinates (pixel values) of our objects. If the distance between the objects
is less than 27 pixels, the function will return True value otherwise the function will
terminate.

Second Part:

After the collision will occur, the following effect will be seen on the display screen.

a) The “explosion.wav” sound will play after the collision of bullet and enemy-spaceship.
The sound will appear like the real sound of war which gives the best experience to user.

b) Both the images object (bullet and enemy space-ship) will disappear at same instant after
explosion sound play.
c) A new enemy space-ship object will appear on the screen to keep remain the amount 6 or
enemies.
d) The next bullet will be activate to shoot instead of able to shoot only after completely
crossing the top of display as of general case.

 Score Section
The Score Section contains the section which has been used in the game to display the score of
the game. For each kill of the enemy space-ship, is supposed as increment by 1 in the score. Of
course, the increment of the score could go higher, but to make the user attentive and ambitious
for the score, increment by 1 seems good.

So, First thing is about we have to deal with the position and fonts used to display the score.
Fonts can be of any choice according to the developer of the game. This allowance comes from
Pygame which facilitate the users to import any Google Fonts and use in their projects.

To importing the fonts from Pygame library or by any external resource, we first need to load the
font-family into our project. This thing can be easily achieved by the “Font ( )” method of
Pygame. Pygame Font method takes 2 parameters to run, the first one is the name of the font-
family, and the next one is the size (i.e. 28, 32 and 64 etc…) which is written as integers or
decimal value and scaled by pixels originally from Pygame. For different sizes at several places,
the method can be stores as the variable so can be used wherever needed.

The method is written as follows into the program:

pygame.font.Font (“Font-Family.txt, size)

After importing the font-family, we need to use that particular font-family for any specified text.
This process can be done by using the render ( ) method of Pygame.
Pygame .render ( ) method takes 3 parameters which are ordered as follows:
1) The first parameter is that specified text value in which user wants to add that font type. This
text value is often type-cast into the string by str( ) function if the variable is taken from
somewhere.
2) Second parameter is the Boolean value either True or False which specify the decision to
rendering the element or not for any condition.
3) Third parameter is the RGB, HEX or HSL value which is used to color the text-value.
Generally HEX and RGB value are used but for variations in contrast, saturation etc, HSL values
are widely used as well.

The Last thing we need to remember while rendering the score is its position. This thing isn’t too
different than the .blit() method of image display. The same thing would be happen here also.

 Game Over Section


The Game Section contains the section which has been used in the game to display the “GAME
OVER” text which would only display when the user would lose the game.

We have centered the game over section when the game loop will end (obviously game loop will
end when the losing condition would be achieved. We are going to use same thing of Score
section here also since we need to use fonts in this case also.
Chapter 5
Limitations and Delimitations

In this project, I’ve put my concentration and effort to pay attention over each of the user
functionality and design but still I can say that there are few things which make this project
unique and some other things which are counted as a delimitation of this project because of it
category.

I can describe them as limitations and delimitations of this project as follows:

6.1 Limitations:-
1) The Game is designed in 2D functionality so doesn’t give the 3D game experience to

user.

2) The movement of enemy spaceships is regular unlike random motion.

3) The Game can only be played by Key Board. User can’t play it by Mouse.

4) There is no High Score Section in the game. Score increase until the game doesn’t over.

5) There is no pause in game while playing.

6.1 Delimitations:-
1) The Game is fast and doesn’t lack somewhere.

2) Bullet movement is quick on behalf of key press.

3) The Game uses the object images stores in Local Computer, so doesn’t require internet.

4) There is no privacy concern regarding the game.

5) User can select any of his chosen images from internet for the background or game

objects while building this game. It doesn’t have any limitation except size which can be

solved by resizing the game display.

6) The Game gives the perfect GUI experience. User can stop or start game anytime.
Chapter 6
Conclusion
At the very end of this report,

I conclude that I’ve successfully build this game in Python


Programming Language. Within this time, I learned the concepts of logic building and uses of
various python built-in functions. This project enhanced my thinking skills and I am glad that I
could successfully implement a game as a project.

The Final Result of this game appears like this.

That was a great experience for me to learn about Pygame and Python commands, since apart of
this project, this gave me a root to move ahead by building several other Python Projects with
more complex logic building.
Chapter 7
References

 https://docs.python.org/3/library/index.html

 https://www.pygame.org/docs/

 https://en.m.wikipedia.org/wiki/Space_Invaders

 https://iconarchive.com/

 https://www.geeksforgeeks.org/pygame-tutorial/amp/

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy