-
Notifications
You must be signed in to change notification settings - Fork 0
Game Model
The central class of the Game Model. It holds and updates all the GameObjects.
- objectStorage: An ArrayList use to handle all all GameObjects
- user: this object is user fish
- 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
- int: id;
- 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
- limitOfFood: limitation of how many foods can appear on the screen.
- limitOfType1Fish: limitation of how many fish1 can appear on the screen.
- limitOfType2Fish: limitation of how many fish2 can appear on the screen.
- limitOfType3Fish: limitation of how many fish3 can appear on the screen.
- limitOfPosionFish: limitation of how many poison fish appear on the screen.
- isCheatModeOn: if cheat mode is on, user fish will not die
- isGameOver: use to handle even while user win or lose
- userfishcollision() use to handle user fish collision with other fish
- circleChecking(int[] circle1, int[] circle2) because all object is circle like shape, check is two objects overlap
- increaseSizeChecker() while user fish reach certain point increase size
- healthAndLifeChecker() use to check life and health
- mineImport() import a mine into game
- 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
- sharkpass(): delete everything on the way the shark passed
- updatanum()check number of fish in the screen and update
- update() updata position for every object
- load(): read the file give the user chance to play the game he saved
- save(): save the current state of game
- situationHandle(AllObject firstobject, AllObject secondObject) handle all the things that may touch together
- userFishOutOfScreenChecker()check userfish out of screen and take it back
- updataDS()updata diection and speed for each object
The class have variable and method that will be used by most object
- 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
- id: fish Id
- objtype: fish type
- ChangeSpeedAndDirection() change speed and direction for each fish this method will be override by children class
- updatePosition() update the position of the object
- getRectangle() use x and y draw a rectangle image
Thisclass extends from AllObject class, all kind of fish class will extend this class
- initialDirection: use to decide to side to import the fish and its initial facing direction
- ChangeSpeedAndDirection(): override the method in parents class, changes speed and direction for each type of fish
- randChangeSpeedAndDirection(): override parent class;
- randDirection(): randomly decide whether fish turning side or not
- randSpeed(): randomly decide that fish is increasing or decreasing in speed.
- eat(AllObject a) handle eat event
This class extends from AllObject
ChangeSpeedAndDirection() override the method in parents class, changes speed and direction for food
This class extends from AllObject
ChangeSpeedAndDirection() override the method in parents class, changes speed and direction for Obstacles
This class extends from AllObject
ChangeSpeedAndDirection() override the method in parents class, changes speed and direction for Shark
This class extends from AllObject
ChangeSpeedAndDirection() override the method in parents class, changes speed and direction for mine
This class extends from Fishes
direction: shows direction of fish stateOflosingLife: record for state of fish while losing life stateOfLosingHealth: record for state of fish while losing health Up: show is user moving up Right: show is user moving right Down: show is user moving down Left: show is user moving left
updatePosition() update position for user fish ChangeSpeedAndDirection() user fish do not do normal change direction and speed Usereat(AllObject a) user fish eat other object stateOfLosingLifeHandle() handle the state of losing life stateOfLosingHealthHandle() handle the state of losing health beeaten(AllObject a) handle when user fish be eaten sameSize() handle when user fish collision with same size fish facingDirection() handle facing direction of user fish
ChangeSpeedAndDirection() override the method in parents class, changes speed and direction for Obstacles