-
Notifications
You must be signed in to change notification settings - Fork 0
Game Model
Tripp312 edited this page Apr 12, 2022
·
29 revisions
.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