Architecture Specification

Class Responsibility Collaboration Divisions


Description: The Game Engine creates and runs our game. It updates the game state, checks if the user has won the level, and is responsible for calling draw from the gamescreen

Justification: Only one class is necessary to keep the update and call the draw function in GameScreen.

Classification: Controller

Responsibility Collaboration Method Implementation
Initialization: Initializes all classes and game components that the game requires to run initialize()
Loading Content: Loads all audio, visual content and level content. loadContent()
Update: Updates all game objects according to the current state of the game. GameStatePhysics update()
Draw: Calls the draw method from GameScreen Game Screen draw()


Description: Represents the entirety of the game’s current state.

Justification: Having the entire state of the game represented in one data structure keeps the game engine cleaner and allows other classes such as Physics access it as needed.

Classification: Model

Responsibility Collaboration Method Implementation
Holds Game Objects: Contains data structures that hold all game objects and features in the current mode. GameEngineRoomState Getters/Setters
Represents Current Game State: Contains the current mode, the victory state, level information, and user accomplishments and intents. GameEngineRoomState Getters/Setters


Description: Contains the entirety of a room (a.k.a. Sublevel)

Justification: Since there are multiple rooms in a level, there should be  class that hold room’s state.

Classification: Model

Responsibility Collaboration Method Implementation
Represents Current Room State: Contains the object list of the room. GameState Getters/Setters


Description: The Game Object class holds data about a game object that will determine how it will be drawn and how it will interact with other objects.

Justification: All the information about a game object can be contained in one class and can be easily updated by the Game Engine.

Classification: Model

Responsibility Collaboration Method Implementation
Holds Permanent and Dynamic Data: Holds methods for changing characteristics about a game object such as: position, orientation, size, velocity Game Engine Getters/Setters


Description: The physics class is a utility class that contains static methods that calculate all interactions between game objects as well as the physical effect of a character’s actions.

Justification: Should be contained in one class so that all physical constants and calculations can be changed in one place.

Classification: Controller

Responsibility Collaboration Method Implementation
Collision Processing: Listen to all the collisions happening in Box2D world and process each collision’s effect. GameObjGameEngine collide(GameObj obj1, GameObj obj2)
Calculate the consequences of rotation: Rotate coral and move game objects according to the rotational movements indicated in gamestate. GameStateGameEngine rotateObject(GameObj o, GameObj ra)
Simulate Object Movement: Simulate object movement according to velocity and force. GameStateGameEngine accelerateCharacter(Character c, float dx, float dy)


Description: This class contains static methods to read and write levels.

Justification: Reading and writing a level should be contained in one class.

Classification: Controller

Responsibility Collaboration Method Implementation
Read and write levels: Read the level file and initialize the game state with its contents. Also, write a level (this is for level editor). GameObjGameEngine loadLevel(FileHandle f)writeLevel(FileHandle f)


Description: Receives user input from the phone device in a controlled way and translates the signals into appropriate changes in the game state.

Justification: Having all user input dealt with in one class allows the Game Engine to focus on performing updates.

Classification: Controller

Responsibility Collaboration Method Implementation
Receives and report touch input: Receives all player input from the phone and creates the appropriate change to the values in GameState. (Accelerometer values are fetched in GameEngine directly) GameState touchDown()touchDragged()touchUp()


Description: The game screen draws all visual components of the game.

Justification: All of the drawing and necessary parameters will be contained and controlled in one class.

Classification: View

Responsibility Collaboration Method Implementation
Display Game: Draws all images and animation. Decides which content to draw based on the game mode (map navigation, playing game, victory, paused) GameState gameDraw(GameState g)
Processes Camera Control Requests: Changes the camera location and magnification. GameState processZoom(GameState g)

Class Dependency Graph


Activity Diagram


Class Interface Details


void initialize()

Allows the game to perform any initialization it needs to before starting to run.

This is where it can query for any required services and load any non-graphic

related content.  Calling base.Initialize will enumerate through any components

and initialize them as well.

void loadContent()

Called once per game.  Loads game content including pictures and music.  Also

and creates a new instance of Level.

void update()

Allows the game to run logic such as updating the world,

checking for collisions, gathering user input, and playing audio.

void draw()

Called when the game draws itself.  Calls drawl method of GameScreen

and GUI.


static void modVelocity(GameObj obj, int x, int y)

Modifies the velocity of game objects.

static void solveVelocity(GameObj a)

Updates game object’s position according to its velocity.

static void accelerateCharacter(Character c, int dx, int dy)

Influences the octopus character with acceleration.  This takes into account user input, collisions as well as currents.

static void applyCurrToFish(GameObj o1, GameObj o2)

o1 is fish object, o2 is current

static void friction(Gamebj obj)

Influences object with friction, dampens horizontal movement.

static boolean detectCollision(GameObj obj1, GameObj obj2)

Detects if obj1 and obj2, given their current trajectories, will collide with one another.

static void collide(GameObj obj1, GameObj obj2)

Resolve the collision of two objects that are about to strike.  Calculate as if they have already struck each other.


static void checkCoralMenu(Coral c, change properties)

Given requests from the Editor’s GUI, update the coral’s properties appropriately.

static void checkCurrentMenu(Current c, change properties)

Given requests from the Editor’s GUI, update the current’s properties appropriately.

static void addObject(GameObj o)

Add the requested object to the level.

static void changePosition(GameObj o, int x, int y)

Change the position of the current object according to the given GUI request


void addToWorld()

Adds the GameObj, its body, as well as all of its shapes into the world.

void removeFromWorld()

destroys the GameObj's body from the world

void die()

sets the GameObj's isDead field to true, so that it can be removed from the world in a safe way


Process move requests for the given character


static void zoomOutLevel()

Zoom out of the given level.

static void zoomInAuto()

Zoom back into the level.

static void cameraSnap()

Center the camera on the character without allowing parts of the screen that are not level to be shown.

static void cameraScrollHorizontal(bool left)

Scroll the camera horizontally.

static void cameraScrollVertical(bool up)

Scroll the camera vertically.

static void drawLevel(GameState gs)

Draw the given level to the screen.


Getter Methods:

Returns the fields that represent the current state of a room

Setter Methods:

Sets the fields that represent the current state of a room.


Getter Methods:

Returns the fields that represent what is currently happening in the game.

Setter Methods:

Sets the fields that represent what is currently happening in the game.

Data Representation Models

Game Level File

Type: XML

Represents: The level file contains the initial layout of a level.

Tag Specifications:

# level (width, height)

# character (x, y)
# room (roomid)

# coral (x, y, width, height)
# rotatingcoral (x, y, length, thickness, orientation)
# urchin (x, y)
# crab (x, y)
# current (x, y, width, height, direction)
# fish (x, y)
# fatfish (x, y)
# home (x, y)

Values of tags:

{x, y, width, height}:Value in pixels

{orientation} : Angle in degrees

{direction}: 0 - None, 1 - Up, 2 - Right, 3 - Down, 4 - Left


























Saved Game File

Type: XML

Represents: Saved game state

Stores which levels the player has completed

Stores the player’s score for each completed level

Tag Specifications:

# SaveState

# CompletedLevels

# Level (LevelID, Score)

# CurrentLevel

# Level (LevelID)



















Third Party Libraries

We will use Libgdx’s Box2D functionality to detect all collisions and simulate the physical collision. For collisions that have consequences that are not implemented in Box2D, such as capturing fish, we will use the Physics class to process them.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License