public class GameEngine
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ENDLESS_MODE |
java.lang.String |
gameMode |
GameWindow |
gameWindow |
static java.lang.String |
LIMITED_MODE |
static int |
LOST |
static int |
STILL_GOING |
static int |
WON |
Constructor and Description |
---|
GameEngine(GameWindow gameWindow,
int numberOfEnemies)
This constructor creates a game in the given window with the given number of enemies and in the default game mode Limited.
|
GameEngine(GameWindow gameWindow,
int numberOfEnemies,
java.lang.String gameMode)
This constructor creates a game in the given window with the given number of enemies and in the specified game mode
It creates ArrayLists with initial estimations of size and creates a player and spawn enemies.
|
Modifier and Type | Method and Description |
---|---|
void |
addBullet(Shooter shooter)
This method creates a bullet with a given shooter and then adds it to the game objects.
|
void |
addGameObject(AbstractGameObject gameObject)
This method adds a game object to the appropriate list.
|
int |
checkEndCondition()
This method checks the state of the win/lose conditions for the current mode
|
void |
cleanUp()
This method is called when game is over.
|
java.util.ArrayList<AbstractGameObject> |
getGameObjects()
This method returns the game objects list.
|
GameWindow.GamePanel |
getGameWindow()
This method returns the actual game panel.
|
int |
getKillCount()
This method returns the kill count.
|
PlayerShip |
getPlayer()
This method return the palyer.
|
void |
manDown(AbstractGameObject deadObject)
The method is called by an object if it's dead.
|
void |
notifyObjectsOfWindow()
This method passes the game window (actually game panel) to a static reference in AbstractGameObject to be used by all game objects.
|
void |
notifyWindowOfObjects()
This method passes the game objects to the window.
|
void |
notifyWindowOfPlayer()
This method passes the player to the window.
|
void |
update()
This method updates the game.
|
public GameWindow gameWindow
public java.lang.String gameMode
public static final java.lang.String LIMITED_MODE
public static final java.lang.String ENDLESS_MODE
public static final int WON
public static final int STILL_GOING
public static final int LOST
public GameEngine(GameWindow gameWindow, int numberOfEnemies, java.lang.String gameMode)
gameWindow
- the window containing the panel the game is drawn onnumberOfEnemies
- the number of enemies or intial enemiesgameMode
- the game mode the game is played inpublic GameEngine(GameWindow gameWindow, int numberOfEnemies)
gameWindow
- the window containing the panel the game is drawn onnumberOfEnemies
- the number of enemies or intial enemiespublic void addGameObject(AbstractGameObject gameObject)
gameObject
- the game objectpublic void addBullet(Shooter shooter)
shooter
- the shooter of the bulletpublic java.util.ArrayList<AbstractGameObject> getGameObjects()
public PlayerShip getPlayer()
public void update()
public int checkEndCondition()
public void manDown(AbstractGameObject deadObject)
deadObject
- the dead objectpublic int getKillCount()
public void notifyWindowOfObjects()
public void notifyWindowOfPlayer()
public void notifyObjectsOfWindow()
public GameWindow.GamePanel getGameWindow()
public void cleanUp()