Files - longle97/GameDesign GitHub Wiki

This is a list of the files used in the project and their descriptions.


src folder:

DeploymentController

Controls the player's actions during the deployment phase:

  • select and deploy ships
  • change ship direction
  • end deployment

DiscoveryController

Handles the battle phase:

  • handles input during the discovery phase
  • if the mouse is clicked that location is 'attacked'
  • determines whether attack was successful or not

EndingGameController

Manages interactions at the end of a game:

  • shows win/lose ratio
  • Shows high score

GameController

Controls the game, user input and displays current state of the game:

  • start a new game
  • exit game
  • creates AI
  • refreshes grid after changes
  • waits for attacks to complete and displays results/sound
  • switches from deployment mode to battle mode
  • AI attacks
  • checks results of attacks from AI and player
  • reads key and mouse input depending on state of game
  • change from different game states
  • sets level difficulty

GameLogic

Opens up the graphics window and loads the resources

GameResources

Populates the window with custom font, images and sounds

GameState

Represents the state of the battleship game play. Determines what the player is doing:

  • viewing the main menu
  • viewing the game menu
  • viewing the high scores
  • editing settings
  • deploying, discovering or ending the game
  • quitting the game

HighScoreController

Responsible for displaying and collecting high score information:

  • keeps the player name and score together
  • scores are compared for scorting
  • high scores are loading from a text file
  • high scores are saved into the text file
  • checks whether a player's score is a high score and displays it

MenuController

Handles the drawing and user interactions from the game menus:

  • text captions for menu items
  • draws the main menu, game menu and settings menu to the screen
  • draws buttons associated with menus
  • determines if a mouse is over one of the menu buttons, and whether it has been clicked
  • displays different menus depending on which button is clicked

UtilityFunctions

Methods for drawing and interacting with the mouse:

  • determines if the mouse is in a certain rectangle, and checks the position
  • draws the player's grid and ships
  • draws a field using the grid and the player's ships
  • draws a field showing attacks made and player ships' locations

Model folder

AIHardPlayer

Hard level AI:

  • AI knows more than other levels
  • will try to destroy a ship when it has found 2 ship tiles
  • two AI states, searching for a ship and targeting the ship
  • generate appropriate coordinates

AIMediumPlayer

Medium level AI:

  • same processes for hard level AI

AIOptions

Shows different AI levels in an enumeration:

  • Easy - total random shooting
  • Medium - marks squares around hits
  • Hard - marks squares around hits but removes shots once it misses

AIPlayer

A type of player that can randomly deploy ships, generate coordinates and shoot at tiles:

  • stores the location of last hit made, which determines difficulty
  • simulate think time by waiting a short period (SwinGame.Delay)

AttackResults

Shows the results after a shot has been made:

  • result of attack
  • description of results
  • where attack occurred

BattleShipsGame

Adds two players to the game, makes sure all ships are deployed before starting:

  • checks if players are destroyed
  • allows players to shoot and swap turns
  • notification of end of attack from player or AI
  • sound effect when attack is completed
  • assigns each player the other's grid as the enemy grid
  • game exits when all ships are destroyed

Direction

Enumeration of the orientation of the ships:

  • LeftRight
  • UpDown

ISeaGrid

Defines the read only interface of the grid:

  • allows each player to see and attack their opponent's grid
  • marks indicated tile as shot

Player

Player has own grid, can see opponent's grid:

  • check if all ships are deployed and if all ships are destroyed
  • sets the enemy player's grid
  • tracks the number of shots the player has made
  • tracks total number of shots missed
  • place ships

ResultsofAttack

Enumeration list of results:

  • hit - the player hit something
  • miss - the player missed
  • destroyed - the player destroyed a ship
  • shotalready - the location was already shot
  • gameover - the player killed all opponent's ships

SeaGrid

The grid which the ships are deployed:

  • width and height of the seagrid
  • if the seagrid changes, it is redrawn
  • number of ships killed
  • checks if all ships are deployed
  • allow ships to be placed on the grid
  • add a ship to the seagrid
  • shows results of tiles that are hit

SeaGridAdapter

Allows for change in a sea grid view:

  • causes grid to be redrawn
  • changes view from ship tile to sea tile
  • widths and height of tile

Ship

Details about the ship:

  • name and size
  • number of hits taken
  • location
  • add tile adds the ship tile
  • clears tile back to sea tile
  • type of ship
  • number of cells a ship occupies
  • records if ship is deployed

ShipName

enumeration of names of ships:

  • None = 0
  • Tug = 1
  • Submarine = 2
  • Destroyer = 3
  • Battleship = 4
  • AircraftCarrier = 5

Tile

  • knows its location on the grid
  • knows if it is a ship
  • knows if it has been shot before
  • check if there is a ship and add ship to a tile
  • remove ship from tile
  • tell the grid what the tile is
  • allows a tile to be shot at
  • throws error if tile has been hit before

TileView

Enumeration for values that are visible for a given tile:

  • sea - the viewer can see sea, may be masking a ship if viewed via sea adapter
  • miss - the viewer knows a site was attacked but nothing was hit
  • ship - the viewer can see a ship at this site
  • hit - the viewer knows the site was attacked and something was hit

Resource Folder

highscores.txt

keeps track of high scores within the game for display in all games

SwinGame.icns

SwinGame for Macintosh

SwinGame.ico

SwinGame for Windows

animations folder

splash.txt

animation for loading screen

startup.txt

animation for startup screen

bundles folder

FileDialog.txt

File dialog for bundles

splash.txt

part of loading screen animation

fonts folder

ariel.ttf

title screen font

cour.ttf

font for score screen and game font

ffaccess.ttf

main menu font

images folder

backgrounds

these images make up the main title screen

  • main_page.jpg
  • discover.jpg
  • deploy.jpg

deployment

these images are used as the buttons on the deployment screen:

  • deploy_dir_button_horiz.png
  • deploy_dir_button_vert.png
  • deploy_button_hl.png
  • deploy_play_button.png
  • deploy_randomize_button.png

ships

these images to create the ships

  • all images starting with "ship_deploy"

loading screen

these images create the loading screen:

  • SplashBack.png
  • SwinGameAni.jpg
  • loader_full.png
  • loader_empty.png

FileDialog pictures

these images make up the file dialog

  • fdFile.png
  • fdFolder.png
  • all images starting with "FileDialog"

explosion effects

these images create the explosion effects

  • explosion.png
  • splash.png

panels folder

FileDialog.txt

file dialog for panels

sounds folder

error.wav

sound played during a player control error

hit.wav

sound played when a player makes a hit in-game

horrordrone.mp3

main background music

lose.wav

sound made when a player has lost

sink.wav

sound made when a player has sunken a ship

SwinGameStart.ogg

loading screen music

watershot.wav

sound played when a player misses

winner.wav

sound played when a player wins



Possible Files not in use

  • "deploy_dir_button_horiz.jpg" and "deploy_dir_button_vert.jpg" have the same image. Possible to remove one and split the other image into two
  • "Swinburne.jpg" not in use
  • "explosion.jpg" only uses one part of its image
  • "spash.jpg" only uses one part of its image
  • "SwinGameStart.wav" wav version of the .ogg file
  • "SwinGameAni.png" png file of a jpg file
  • "siren.wav" implemented but does not exist in the resources folder
  • "FileDialog.txt" buttons described not being used / have no images
  • "AIEasy.vb" used but non-existent. probably needs to be created
  • fdfile/fdfolder and associated images are not being used for anything
  • All FileDialogs files are not being used