top of page

PS Vita, C++

Trench Assault AR Game

​The Game

This was developed for the Applied Game Technologies module and makes use of the PS Vita's AR marker tracking technology.

​​

The game allows the player to control an "X-Wing" spacecraft in first person to navigate the Star Wars trench run, avoiding obstacles and shooting asteroids in their path. Two AR markers are used to determine the size of the game level, this allows the player to customise the trench’s size. 

Application Features

  • Main Menu – The user can navigate a main menu to start the game, exit or look over the game’s controls.

  • On Screen Tutorial - If the game is started, the user will be taken through on-screen tutorial to be guided through how to set up the level and play the game 

  • Custom Trench size editor – Using AR Markers 1 and 2, the user can place these on a flat surface which determines the corners of the level. Once saved, the level is drawn using the distance between the markers and placed on top of Marker 1. This distance can be adjusted at any time.

  • Move the PS Vita to dodge – The user must move their player using the PS Vita to avoid obstacles spawning from the marker location while keeping within boundary of the trench walls.

  • Shoot destroyable obstacles – The user can move the aim cursor, with the analogue sticks, to determine the direction of the projectile which is fired down the cameras Z position. These can be used to destroy some obstacles (asteroids).

​

3 Levels:

  • Level 1 introduces wall obstacles which have to be avoided to survive.

  • Level 2 includes asteroids to dodge, which are more frequent but can also be destroyed with the laser turret.

  • The final level is a simple task – fire the Proton Torpedoes into the exhaust shaft to destroy the Death Star. 

How It Works

Level 1 - Cubes
This level is made by randomly scaled and positioned cube obstacles. These cubes spawn on each side of the trench walls and extrude by a random amount from the walls they are connected to.
The cubes are given a random X and Y position and a Z position that places them consecutively down the trench a certain distance apart. A constant velocity is then applied which moves them towards the player to give the illusion the player is moving down the trench past the obstacles.
 
 
Level 2 - Asteroids
This uses a similar method to the cubes, but uses an asteroids model instead and scales them in all axes so they form to their meshes bounding sphere. They are placed consecutively down the trench in the Z axis and a similar constant velocity as well as a random angular velocity to make them spin in all axes.



 

 


Setting up Trench Walls
During the tutorial, if both markers are found, the X and Y distance components between the markers will be calculated, and the setup cube will be then be rendered relative to marker 1 but positioned halfway between the markers and will scale to the distance, shown below.

Once X is pressed, the trench walls are rendered and the wall setup function saves the current X and Y. It uses these to set scale and positions for the trench walls in relation to marker 1 (the reference marker). This is the area in which the game is played.

wall1.png
ast2.png
setup2.png
setup1.png
setup3.png

Out of bounds check

This uses the player’s (camera) position relative to the marker, calculated by finding the inverse of the marker transform. It checks whether the player is above a certain height and removes a life they are.

outofbounds.png

Software Design

Below is a state flow diagram detailing how the different game states interact with each other. For the Win and Lose states, these are instead defined using booleans, as there are only 2 states they can be, but the diagram uses them to show how restarting works in the game.

stateflow.png

Classes

  • AR_App - Main application class, used for switching between game states (SPLASH, MENU, GAME)

  • Splashscreen - Updates and renders splash screen

  • MenuManager - Updates and renders Menu screen as well as the help screen

  • GameManager - Updates and renders the game state, includes AR marker information and collision detection functions. It contains an enumerated type for all the Levels in the game, and a Struct container for holding marker information such as their transform, a boolean for finding the marker and their transform relative to the reference marker (marker 1). 

  • GameObject - Inherited from MeshInstance, holds all matrix info and calculations for mesh objects. Can be used to set rotations, scales and translations, velocity etc

Software Evaluation

There were a number of improvements to the game that were not implemented due to time restraints. Better use of classes would have improved code usability, readability and reduced reused code. Polymorphism with virtual functions could have been beneficial when creating classes for each game state, as they all use the same basic functions (Render, update, clean up). A Class for holding Level data and having a list of Level objects to contain them would make it easier to add more levels. Furthermore, splitting up the GameManager Class into more classes would have made a more readable game Update function. Instead of having multiple level state switch statements in Game Update, one switch statement to control the level state would have been more efficient.

bottom of page