Professional Documents
Culture Documents
Ilovepdf Merged
Ilovepdf Merged
A
Mini Project Report
On
Nikitha D [1JB20CS071]
Nischitha B[1JB20CS073]
Mrs. Rajatha
Assistant Professor
Dept. of CSE
CERTIFICATE
This is to certify that the mini project report entitled “Space Shooter Game” is a
bonafied work carried out Nikitha D [1JB20CS071], Nischitha B [1JB20CS073] in partial
fulfillment of mini project of 6th semester Mobile Application Development Laboratory
(18CSMP68) in COMPUTER SCIENCE AND ENGINEERING of VISVESVARAYA
TECHNOLOGICAL UNIVERSITY, BELGAUM, during the academic year 2022-2023. It is
certified that all corrections/suggestions have been incorporated in the report deposited in the
department library. The mini project report has been approved as it satisfies the academic
requirements.
___________________ ___________________
Signature of the guide Signature of the HOD
Mrs. Rajatha Dr. Krishna A N
Asst. Professor Professor & Head
Dept. of CSE Dept. of CSE
1. _______________________ __________________________
2. _______________________ __________________________
ACKNOWLEDGEMENT
We would like to express our profound gratefulness to His Divine Soul Jagadguru
Padmabhushana Sri Sri Sri Dr. Balagangadharanatha Mahaswamiji and His Holiness
Jagadguru Sri Sri Sri Dr. Nirmalanandanatha Mahaswamiji for providing me with an
opportunity to study in this esteemed Institution.
We would like to express our profound thanks to Reverend Sri Sri Dr. Prakashnath Swamiji,
Managing Director, SJB Institute of Technology, for his continuous support in providing
amenities to carry out this mini project in this admired institution.
We extend our sincere thanks to Dr. Krishna A N, Head of the Department of Computer Science
and Engineering, for providing me with invaluable support throughout the period of my mini
project.
We wish to express our heartfelt gratitude to our guides, Mrs. Rajatha, Assistant professor,
Dept. of CSE for their valuable guidance, suggestions and cheerful encouragement during the
entire period of this min project work.
Finally, We take this opportunity to extend our earnest gratitude and respect to our parents,
Teaching & Non-teaching staffs of the department, the library staff and all our friends, who have
directly or indirectly supported me during the period of our mini project work.
Regards,
Nikitha D [1JB20CS071]
Nischitha B [1JB20CS073]
ABSTRACT
The rapid evolution of mobile technology has transformed the way we consume and
interact with game. Mobile games are now a way of relaxing and have indeed become a part of
our daily lives. ”Space Shooter is a simple, yet addictive, space shooter game developed in
Android Studio." The proposed approach is designed to make space shooter games more
accessible to a wider audience. By simplifying the controls and relaxing the pace, the game can
be enjoyed by players of all skill levels. The game is a single-player game that is played from a
top-down perspective. The player controls a spaceship that can move left, right, up, and down.
The player can also shoot bullets at enemies. The goal of the game is to survive as long as
possible by destroying enemy ships. The game is easy and simple to play. It has intuitive controls
that are easy to learn and straightforward gameplay that is easy to follow. This makes it a great
game for beginners and casual gamers who are looking for a fun and relaxing experience.
ii
TABLE OF CONTENTS
Acknowledgement i
Abstract ii
List of Figures v
List of Tables vi
Chapter 1 INTRODUCTION
1.3 Java 2
1.4 Xml 3
1.8 Advantages 4
2.1 Introduction 5
2.6 Platform 6
3.1 Flowchart 7
3.2 Algorithm 8
Chapter 4 IMPLEMENATION
4.1 Java 10
4.2 Implementation Code 10
4.3 Code Snippet 11
4.3.1 MainActivity.java 11
4.3.2 OurSpaceShip.java 11
4.3.3 Shot.java 12
iii
4.3.4 SpaceShooter.java 13
4.3.5 Explosion.java 19
4.3.6 GameOver.java 20
4.3.7 StartUp.java 21
4.3.8 Manifest.xml 22
Chapter 5 SNAPSHOTS 23
Chapter 6 CONCLUSION 26
REFERENCES 27
iv
List Of Figures
v
List of Tables
vi
Space Shooter Game
CHAPTER 1
INTRODUCTION
” Space Shooter is a simple, yet addictive, space shooter game developed in Android
Studio." The proposed approach is designed to make space shooter games more accessible to a
wider audience. By simplifying the controls and relaxing the pace, the game can be enjoyed by
players of all skill levels. The game is a single-player game that is played from a top-down
perspective. The player controls a spaceship that can move left, right, up, and down. The player
can also shoot bullets at enemies. The goal of the game is to survive as long as possible by
destroying enemy ships. The game is easy and simple to play. It has intuitive controls that are easy
to learn and straightforward gameplay that is easy to follow.
Mobile application development is a term used to denote the act or process by which
application software is developed for handheld devices, such as personal digital assistants,
enterprise digital assistants or mobile phones. These applications can be pre- installed on phones
during manufacturing platforms or delivered as web applications using server-side or User
interface design (UI) or user interface engineering is the design of user interfaces for machines
and software, such as computers, home appliances, mobile devices, and other electronic devices,
with the focus on maximizing the user experience. The goal of user interface design is to make
the user's interaction as simple and efficient as possible; in terms of accomplishing user goals
(user-centered design). Good user interface design facilitates finishing the task at hand without
drawing unnecessary attention to it. Graphic design and typography are utilized to support its
usability, influencing how the user performs certain interactions and improving the aesthetic
appeal of the design.
ADVANTAGES:
• Improves Efficiency.
• Offers High Scalability.
• Secures the App Data.
• Easy to Maintain.
• Improves Customer Relationship
• Facilitates New Client Data Retrieval.
• Provides Real-time Project Access.
• Ease in Project Management.
Android Studio is the official Integrated Development Environment (IDE) for Android
app development, based on IntelliJ IDEA software. It provides the fastest tools for building apps
on every type of android device. It is a purpose-built for android to accelerate the development
and helps to build the highest-quality apps for every android device.
FEATURES:
• A flexible Gradle-based build system.
• A unified environment where one can develop for all Android devices.
• Apply Changes to push code and resource changes to the running app without restarting the
app.
• Extensive testing tools and frameworks.
• Lint tools to catch performance, usability, version compatibility, and other problems C++
and NDK support.
• Built-in support for Google Cloud Platform, making it easy to integrate Google Cloud
Messaging and App Engine.
1.3 Java
FEATURES OF JAVA:
1.4 XML
Extensible Markup Language (XML) is a markup language that defines a set of rules for
encoding documents in a format that is both human-readable and machine- readable. The design
goals of XML focus on simplicity, generality, and usability across the Internet. It is a textual data
format with strong support via Unicode for different human languages. Although the design of
XML focuses on documents, the language is widely used for the representation of arbitrary data
structures such as those used in web services.
FEATURES OF XML:
This is a complete project of a simple 2D space shooter game . The game contains all the
"ingredients" needed to learn the paradigms underlying videogames development including (but
not limited to) player-enemies interaction, How the invaders & attacker shoots, GUI ,explosion
animation, game start/end proceed and How to calculate points and many more.
The objective of a space shooter game is to control a spacecraft or a character and engage
in combat with enemy spaceships or other hostile entities in a space-themed environment. The
primary goal is usually to destroy enemies while avoiding or surviving their attacks. space
shooter game is to provide an exciting and immersive experience, combining skillful shooting,
reflexes, and strategic decision-making to overcome challenges and emerge victorious in the
vastness of space.
1.8 Advantages
• User Interface
• Easy maintenance
• Best User Experience
• People can enjoy the news anytime and anywhere
• Frequent news updates
• Provide diverse content
CHAPTER 2
SYSTEM REQUIREMENTS
2.1 Introduction
Requirements are during early stages of a system development as a specification of what
should be implemented or as a constraint of some kind of on the system. They may be a user
level facility descript -ion, a detailed specification of expected system behavior, a general
system property, a specific contai -nt on the system, and information on how to carry out some
computation or a constraint on the devel -opment of the system. System requirements are more
detailed descriptions of the user requirements. They are used by software engineers as the
starting point of system design. In principle, the system requirements should state what the
system should do and not how it should be implemented.
2.6 Platform
The platform organizations need to develop, deploy and manage mobile applications is made
from many components, and tools allow a developer to write, test and deploy.
Front-end development tools are focused on the user interface and user experience (UI/UX)
and provide the following capabilities:
• UI design tools
• SDKs to access device features
• Cross-platform accommodations/support
Back-end servers
Back-end tools pick up where the front-end tools leave off, and provide a set of reusable
services that are centrally managed and controlled and provide the following capabilities:
• Integration with back-end systems
• User authentication/authorization
• Data services
• Reusable business logic
The security is more important within more enterprises, IT departments often need stopgap,
tactical solutions that layer on top of existing apps, phones, and platform component.
• App wrapping for security.
• Data encryption
• Client actions
• Reporting and statistics
CHAPTER 3
SYSTEM DESIGN
3.2 Algorithm
Initialize the game:
● Set up the game screen, player ship, and score.
● Display the main menu.
Handle user input:
● Listen for user input to choose options from the main menu (play or exit) and level selection.
● Handle input for player ship movement and shooting during gameplay.
Start the game:
● If the player chooses to play:
1. Initialize the chosen level with appropriate enemy configurations and level settings.
2. Display the level selection screen.
Game loop:
● While the player ship is alive and enemies exist:
1. Update the player ship's position and handle shooting.
2. Update enemy positions and behavior.
3. Detect collisions between the player ship and enemies.
4. Update the score and destroy enemies upon collision.
Table no 3.1:
1. Text View
A TextView displays text to the user and optionally
allows them to edit it. A TextView is a complete text
editor, however the basic class is configured to not
allow editing.
2. Edit Text
A EditText is an overlay over TextView that
configures itself to be editable. It is the predefined
subclass of TextView that includes rich editing
capabilities.
3. Button
In Android, Button represents a push button. A Push
buttons can be clicked, or pressed by the user to
perform an action.
CHAPTER 4
IMPLEMENTATION
4.1. Java
There are several ways to create apps for Android devices, but their commended method
for most developers is to write native apps using Java and the Android SDK. Java for Android
apps is both similar and quite different from other types of Java applications. If you have
experience with Java (or a similar language) then you’ll probably feel comfortable diving right
into the code and learning how to use the Android SDK to make your app run. But if you’re new
to programming or object- oriented languages then you’ll probably want to get familiar with the
syntax of the Java language and how to accomplish basic programming tasks before learning
how to use the Android SDK.
Fig 4.1 shows the overview of the files in the application. Which contains many modules like
MainActivity, EnemySpaceship, Explosion, GameOver, OurSpaceship ,Shot, SpaceShooter
StartUp and many other.
package com.example.spaceshooters;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new SpaceShooter(this));
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
protected void onPause() {
super.onPause();
}
}
4.3.2 OurSpaceship.java
package com.example.spaceshooters;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import java.util.Random;
public class OurSpaceship {
Context context;
Bitmap ourSpaceship;
int ox, oy;
Random random;
public OurSpaceship(Context context) {
this.context = context;
4.3.3 Shot.java
package com.example.spaceshooters;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
public class Shot {
Bitmap shot;
Context context;
int shx, shy;
public Shot(Context context, int shx, int shy) {
this.context = context;
shot = BitmapFactory.decodeResource(context.getResources(),
R.drawable.shot);
this.shx = shx;
this.shy = shy;
}
public Bitmap getShot(){
return shot;
}
public int getShotWidth() {
return shot.getWidth();
}
public int getShotHeight() {
return shot.getHeight();
}
}
4.3.4 SpaceShooter.java
package com.example.spaceshooters;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.os.Handler;
import android.view.Display;
import android.view.MotionEvent;
import android.view.View;
import java.util.ArrayList;
import java.util.Random;
@Override
protected void onDraw(Canvas canvas) {
// Draw background, Points and life on Canvas
canvas.drawBitmap(background, 0, 0, null);
canvas.drawText("Pt: " + points, 0, TEXT_SIZE, scorePaint);
for(int i=life; i>=1; i--){
canvas.drawBitmap(lifeImage, screenWidth - lifeImage.getWidth() * i, 0, null);
}
// When life becomes 0, stop game and launch GameOver Activity with points
if(life == 0){
paused = true;
handler = null;
Intent intent = new Intent(context, GameOver.class);
intent.putExtra("points", points);
context.startActivity(intent);
((Activity) context).finish();
}
// Move enemySpaceship
enemySpaceship.ex += enemySpaceship.enemyVelocity;
// If enemySpaceship collides with right wall, reverse enemyVelocity
if(enemySpaceship.ex + enemySpaceship.getEnemySpaceshipWidth() >= screenWidth){
enemySpaceship.enemyVelocity *= -1;
}
// If enemySpaceship collides with left wall, again reverse enemyVelocity
if(enemySpaceship.ex <=0){
enemySpaceship.enemyVelocity *= -1;
}
// Till enemyShotAction is false, enemy should fire shots from random travelled distance
if(enemyShotAction == false){
if(enemySpaceship.ex >= 200 + random.nextInt(400)){
Shot enemyShot = new Shot(context, enemySpaceship.ex +
enemySpaceship.getEnemySpaceshipWidth() / 2, enemySpaceship.ey );
enemyShots.add(enemyShot);
// We're making enemyShotAction to true so that enemy can take a short at a time
enemyShotAction = true;
}
if(enemySpaceship.ex >= 400 + random.nextInt(800)){
Shot enemyShot = new Shot(context, enemySpaceship.ex +
enemySpaceship.getEnemySpaceshipWidth() / 2, enemySpaceship.ey );
enemyShots.add(enemyShot);
// We're making enemyShotAction to true so that enemy can take a short at a time
enemyShotAction = true;
}
else{
Shot enemyShot = new Shot(context, enemySpaceship.ex +
enemySpaceship.getEnemySpaceshipWidth() / 2, enemySpaceship.ey );
enemyShots.add(enemyShot);
// We're making enemyShotAction to true so that enemy can take a short at a time
enemyShotAction = true;
}
}
// Draw the enemy Spaceship
canvas.drawBitmap(enemySpaceship.getEnemySpaceship(), enemySpaceship.ex,
enemySpaceship.ey, null);
// Draw our spaceship between the left and right edge of the screen
if(ourSpaceship.ox > screenWidth - ourSpaceship.getOurSpaceshipWidth()){
ourSpaceship.ox = screenWidth - ourSpaceship.getOurSpaceshipWidth();
}else if(ourSpaceship.ox < 0){
ourSpaceship.ox = 0;
}
// Draw our Spaceship
canvas.drawBitmap(ourSpaceship.getOurSpaceship(), ourSpaceship.ox, ourSpaceship.oy,
null);
// Draw the enemy shot downwards our spaceship and if it's being hit, decrement life,
remove
// the shot object from enemyShots ArrayList and show an explosion.
// Else if, it goes away through the bottom edge of the screen also remove
// the shot object from enemyShots.
enemySpaceship.getEnemySpaceshipWidth()
&& ourShots.get(i).shy <= enemySpaceship.getEnemySpaceshipWidth()
&& ourShots.get(i).shy >= enemySpaceship.ey){
points++;
ourShots.remove(i);
explosion = new Explosion(context, enemySpaceship.ex, enemySpaceship.ey);
explosions.add(explosion);
}else if(ourShots.get(i).shy <=0){
ourShots.remove(i);
}
}
// Do the explosion
for(int i=0; i < explosions.size(); i++){
canvas.drawBitmap(explosions.get(i).getExplosion(explosions.get(i).explosionFrame),
explosions.get(i).eX, explosions.get(i).eY, null);
explosions.get(i).explosionFrame++;
if(explosions.get(i).explosionFrame > 8){
explosions.remove(i);
}
}
// If not paused, we’ll call the postDelayed() method on handler object
// run method inside Runnable to be executed after 30 milliseconds, that is the value inside
// UPDATE_MILLIS.
if(!paused)
handler.postDelayed(runnable, UPDATE_MILLIS);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
int touchX = (int)event.getX();
// When event.getAction() is MotionEvent.ACTION_UP, if ourShots arraylist size < 1,
// create a new Shot.
// This way we restrict ourselves of making just one shot at a time, on the screen.
if(event.getAction() == MotionEvent.ACTION_UP){
if(ourShots.size() < 1){
4.3.5 Explosion.java
package com.example.spaceshooters;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
public class Explosion {
Bitmap explosion[] = new Bitmap[9];
int explosionFrame;
int eX, eY;
R.drawable.explosion1);
explosion[2] = BitmapFactory.decodeResource(context.getResources(),
R.drawable.explosion2);
explosion[3] = BitmapFactory.decodeResource(context.getResources(),
R.drawable.explosion3);
explosion[4] = BitmapFactory.decodeResource(context.getResources(),
R.drawable.explosion4);
explosion[5] = BitmapFactory.decodeResource(context.getResources(),
R.drawable.explosion5);
explosion[6] = BitmapFactory.decodeResource(context.getResources(),
R.drawable.explosion6);
explosion[7] = BitmapFactory.decodeResource(context.getResources(),
R.drawable.explosion7);
explosion[8] = BitmapFactory.decodeResource(context.getResources(),
R.drawable.explosion8);
explosionFrame = 0;
this.eX = eX;
this.eY = eY;
}
4.3.6 GameOver.java
package com.example.spaceshooters;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
public class GameOver extends AppCompatActivity {
TextView tvPoints;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.game_over);
int points = getIntent().getExtras().getInt("points");
tvPoints = findViewById(R.id.tvPoints);
tvPoints.setText("" + points);
}
public void restart(View view) {
Intent intent = new Intent(GameOver.this, StartUp.class);
startActivity(intent);
finish();
}
public void exit(View view) {
finish();
}
}
4.3.7 StartUp.java
package com.example.spaceshooters;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
public class StartUp extends AppCompatActivity {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.startup);
}
public void startGame(View view) {
startActivity(new Intent(this, MainActivity.class));
finish();
}
4.3.8 Manifest.xml
</manifest>
CHAPTER 5
SNAPSHOTS
Fig 5.4 Once the game starts we can see that the player should protect his space rocket from
being shot by the enemy ship. you can also see the explosion once bullet is shot to the enemy
ship.
CONCLUSION
The space shooter project is an Android game that offers thrilling shooting action in a space-
themed setting. It includes features like player ship movement, shooting mechanics, enemy
generation, scoring, and game over conditions. The game aims to provide an immersive and
enjoyable gaming experience with responsive controls and smooth performance. Through
testing, the project ensures the accuracy of internal mechanisms and verifies user experience
aspects such as controls, level progression, and stability. Overall, the space shooter project aims
to deliver an engaging and polished Android game for players to enjoy.
REFERENCE BOOKS
WEBSITE LINKS
[1]. https://youtu.be/YNq6B_VEvRI
[2]. https://www.udemy.com/course/android -game-development-tutorial-in-android-studio/
[3]. https://developer.android.com/docs
[4]. https://app.diagrams.net