Skip to content

Game Model

ShubinJerry-Yuan edited this page Apr 3, 2021 · 18 revisions

FishGame

The central class of the Game Model. It holds and updates all the GameObjects.

Variables

  • objectStorage: An ArrayList use to handle all all GameObjects
  • life: the number of life of the user remains
  • points: the number of points user receive from eating food and other fishes
  • health: the number of health that user remains
  • level: the current level that the player is in
  • numberOfFood: the number of food that currently exists
  • numberOfType1Fish: the number of the first type of fish that currently exists
  • numberOfType2Fish: the number of the second type of fish food that currently exists
  • numberOfType3Fish: the number of the third type of fish food that currently exists
  • numberOfPoisonFish: the number of the poison fish type of fish food that currently exists
  • isCheatModeOn: if cheat mode is on, user fish will not die
  • isGameOver: use to handle even while user win or lose

Methods

  • Fishmeet(): handle while two fish touch each other
  • blockingArea(): block the area that do not allow user to swim cross
  • add(AllObject a): adds a new GameObject to the FishGame list
  • remove(AllObject a): removes a GameObject from the FishGame list
  • enableCheatMode(): turns cheat mode on
  • disableCheatMode(): turns cheat mode off
  • addshark(): Add a shark to the FishGame list

AllObject

The class have variable and method that will be used by most object

Variables

  • x: the x coordinate of the object
  • y: the y coordinate of the object
  • speed: the speed of the object
  • size: the size of the object
  • direction: the direction of the object facing

Methods

  • ChangeSpeedAndDirection() change speed and direction for each fish this method will be override by children class
  • updatePosition() update the position of the object

Fishes

the class extends from AllObject class, all kind of fish class will extend this class

Variables

  • initialDirection: use to decide to side to import the fish and its initial facing direction

Methods

  • ChangeSpeedAndDirection(): override the method in parents class, changes speed and direction for each type of fish
  • randDirection(): randomly decide whether fish turning side or not
  • randSpeed(): randomly decide that fish is increasing or decreasing in speed.

Clone this wiki locally