Shooter Game Yes Yes
Shooter Game Yes Yes
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:
Secure: With Java’s secure feature it enables to develop virus-free, tamper-free systems.
Authentication techniques are based on public-key encryption.
Architecture-neutral: Java compiler generates an architecture-neutral object file format,
which makes the compiled code executable on many processors, with the presence of Java
runtime system.
Portable: Being architecture-neutral and having no implementation dependent aspects of
the specification makes Java portable. The compiler in Java is written in ANSI C with a
clean portability boundary, which is a POSIX subset.
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.
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
user ,user will loose one life ,once all the life of user is over points screen is displayed and user
can press exit button to close the game and retry button to restart the game .
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:
SL FUNCTION DESCRIPTION
NO.
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;
int life = 3;
Paint scorePaint;
int TEXT_SIZE = 80;
boolean paused = false;
OurSpaceship ourSpaceship;
EnemySpaceship enemySpaceship;
Random random;
ArrayList<Shot> enemyShots, ourShots;
Explosion explosion;
ArrayList<Explosion> explosions;
boolean enemyShotAction = false;
final Runnable runnable = new Runnable() {
@Override
public void run() {
invalidate();
}
};
public SpaceShooter(Context context) {
super(context);
this.context = context;
Display display = ((Activity) getContext()).getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
screenWidth = size.x;
screenHeight = size.y;
random = new Random();
enemyShots = new ArrayList<>();
ourShots = new ArrayList<>();
explosions = new ArrayList<>();
ourSpaceship = new OurSpaceship(context);
enemySpaceship = new EnemySpaceship(context);
handler = new Handler();
background = BitmapFactory.decodeResource(context.getResources(), R.drawable.bg);
lifeImage = BitmapFactory.decodeResource(context.getResources(), R.drawable.life);
scorePaint = new Paint();
scorePaint.setColor(Color.RED);
scorePaint.setTextSize(TEXT_SIZE);
scorePaint.setTextAlign(Paint.Align.LEFT);
}
@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)){
null);
if((ourShots.get(i).shx >= enemySpaceship.ex)
&& ourShots.get(i).shx <= enemySpaceship.ex +
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){
Shot ourShot = new Shot(context, ourSpaceship.ox +
ourSpaceship.getOurSpaceshipWidth() / 2, ourSpaceship.oy);
ourShots.add(ourShot);
}
}
// When event.getAction() is MotionEvent.ACTION_DOWN, control ourSpaceship
if(event.getAction() == MotionEvent.ACTION_DOWN){
ourSpaceship.ox = touchX;
}
// When event.getAction() is MotionEvent.ACTION_MOVE, control ourSpaceship
// along with the touch.
if(event.getAction() == MotionEvent.ACTION_MOVE){
ourSpaceship.ox = touchX;
}
// Returning true in an onTouchEvent() tells Android system that you already handled
// the touch event and no further handling is required.
return true;
}
}
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;
explosion[0] = BitmapFactory.decodeResource(context.getResources(),
R.drawable.explosion0);
explosion[1] = BitmapFactory.decodeResource(context.getResources(),
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) {
4.3.8 Manifest.xml
</manifest>
CHAPTER 5
SNAPSHOTS
and enemy space ship is present ,user can move the rocket left and right by dragging them
around the screen ,at beginning score Pt is set to zero and the life is set to three chances.
Fig 5.3 shows the view of game while playing the points gets updated when user ship bullet
hits the enemy space ship and when enemy space ships bullets hits the user rocket a life gets
reduced by losing one life.
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.
Fig 5.5 Once the game finishes the points scored by the player will be displayed on the screen.
Along with retry button at top left corner and exit button at top right corner , if the player
wishes to play another retry button can be press or else to exit exit button can be pressed to
terminate the game.
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.