-
Notifications
You must be signed in to change notification settings - Fork 0
Game Model
.png)
The singleton that holds all levels in the game model and updates all entities within. One of two central classes in the game model.
Variables:
- campaign: holds all levels to be played
- currentLevel: index of the current level in the campaign
- difficulty: integer equivalent of the selected difficulty
- world: private static variable of the world
- observer: Screenobserver used to update the view on every timer tick
Methods:
- reset(): creates a new instance of world
- instance(): calls the current instance of world
- World(): constructor
- passLevel(): increases currentLevel by one and moves the player accordingly
- getCurrentEntities(): obtains all entities on the current screen
- getCurrentLevel(): returns currentLevel in the campaign
- getPlayer(): returns the current instance of player
- populate(): creates the base gameState without the level builder
- updater(): contains the timer that prompts all movement in the game
- update(): called by updater, calls all on-screen entities' performMovement() method
- save(): saves the current state of the game
- load(): loads the saved state of the game
The other central class of the game model. Displays all the player will interact with, class that View is most entwined with.
Variables:
- screens: this holds an arraylist of screens which the player travels between.
- totalEnemies: holds an arraylist of enemies within each level
- currentScreen: screen that the player currently inhabits
- currentRow: row of the currentScreen in the imaginary Array[][] of screens
- currentCol: column of the currentScreen in the imaginary Array[][] of screens
- currentLevel: level that the player is on
- observer: ScreenObserver used to update the View whenever player enters a new screen
- rand: Random object used to generate screen obstacles
Methods:
- Level(): Level constructor
- setObserver(): sets the passed ScreenObserver to the observer variable
- findScreen(): finds the screen with the given row and column parameters
- placeEntity(): places the entity in the screen with the given row, column
- goLeft(): sets the currentScreen to the one to its left, updates View
- goRight(): sets the currentScreen to the one to its right, updates View
- goUp(): sets the currentScreen to the one above, updates View
- goDown(): sets the currentScreen to the one below, updates View
- getScreens(): returns screens
- setScreens(): sets screens to passed parameter
- addScreen(): adds the param screen to screens
- getCurrentRow(): returns currentRow
- setCurrentRow(): sets currentRow to the passed param
- getCurrentCol(): returns currentCol
- setCurrentCol(): sets currentCol to the passed param
- getCurrentScreen(): returns currentScreen
The object containing all that is displayed to the View at any given time
Variables:
- grid: the Array[][] of cells in each screen that tells whether an obstacle, enemy, player, or nothing is there
- entities: tells which entities inhabit the screen at any given time
- location: gives the screen's location within the world and its level (row, column, level)
- left: screen immediately to the screen's left
- right: screen immediately to the screen's right
- up: screen immediately above the screen
- down: screen immediately below the screen
- rand: Random object to populate the grid with obstacles
Methods:
- Screen(): constructor for the screen
- getLeft(): returns left
- getRight(): returns right
- getUp(): returns up
- getDown(): returns down
- getLocation(): returns location
- randomize(): randomly places obstacles in the screen
- addEnemyGroup(): adds an entire group of enemies to entities
- addEntity(): adds a single entity to entities
- findObstacles(): returns all obstacles in the screen
- removePlayer(): removes the player from the current screen, returns the player that was removed
Gives the unique ID of each screen in each level
Variables:
- row: row in the imaginary Array[][] of screens in each level
- col: column in the imaginary Array[][] of screens in each level
- level: home level of each screen
Methods:
- Location(): constructor for Location
- getRow(): returns row
- setRow(): sets row to the passed param
- getCol(): returns col
- setCol(): sets col to the passed param
- getLevel(): returns level
- setLevel(): sets level to the passed param
Observer to update the View in the case of a change to the model
Methods:
- Initialize(): Method inside the view to be indirectly executed my the model
Used by model to represent hitboxes for attacking and collisions
Enums:
- empty: nothing occupies this cell
- rock: a rock occupies this cell
- tree: a tree occupies this cell
- plant: a plant occupies this cell
- enemy: an enemy occupies this cell
Used by enemies to represent where they face in pathfinding
enums:
- up: object faces up
- down: object faces down
- right: object faces right
- left: object faces left
used by View to display obstacles from the model to itself
Variables:
- row: row location in the screen's grid
- col: column location in the screen's grid
- type: Cell type of the cell
Methods:
- Obstacle(): constructor of obstacle
- getX(): returns X interpretation of col
- getY(): returns Y interpretation of row
- getImage(): returns Image interpretation of type
- Utilized by all entities to represent their location within their home screen
Properties:
- xCoord: property that represents the entity's x location within its screen
- yCoord: property that represents teh entity's y location within its screen
Methods:
- Coordinates(): constructor of Coordinates
- randomCoordinates(): randomizes the creation of coordinates
- getXCoord(): returns the integer value of the property xCoord
- getYCoord(): returns the integer value of the property yCoord
- setxCoord(): sets the integer value of the property xCoord to the passed param
- setyCoord(): sets the integer value of the property yCoord to the passed param
- addXCoord(): adds the passed param to the integer value of the xCoord
- subXCoord(): subtracts the passed param to the integer value of the xCoord
- addYCoord(): adds the passed param to the integer value of the yCoord
- subYCoord(): subtracts the passed param to the integer value of the yCoord
- getXProperty(): returns xCoord
- getYProperty(): returns yCoord
Overarching ancestor class of all that populates the World, its levels, and their screens
Variables:
- image: View representation of the model object
- coordinates: represents the x and y coordinates of the entity
Methods:
- Entity(): constructor for the entity
- performMovement(): moves every entity according to its own Overriding method
- getX(): returns integer value of xCoord in coordinates
- getY(): returns integer value of yCoord in coordinates
- getXProperty(): returns xCoord in coordinates
- getYProperty(): returns yCoord in coordinates
- getImage(): returns image
Collection of all entities that oppose the player throughout the game