public class SuperJumperGame extends GameSession |
public static enum GameState RUNNING, PAUSED, READY, WIN |
private GameState gameState; |
private AudioNode audioNodes; |
public SuperJumperGame() |
// Configuring AudioNodes |
this.audioNodes = new AudioNode |
new AudioNode("coinSound", "res/superjumper/coin.wav"), // ⋯ |
new AudioNode("gameMusic", "res/superjumper/music.mp3") ; |
// Configuring Observers |
this.addObserver(new CheckForNewHighScore(this)); |
this.addObserver(new CheckGameOver(this)); |
// Configuring Behaviors |
this.addBehavior("changeToMenu", new ChangeToMainMenuScreen(this)); |
this.addBehavior("generateLevel", new GenerateLevel(this)); |
this.addBehavior("createHud", new CreateHud(this)); |
this.addBehavior("resetBob", new ResetBob()); |
this.addBehavior(GameState.RUNNING.toString(), new UpdateRunning(this)); |
this.addBehavior("endGame", new EndGame(this)); |
this.addBehavior("playClickSound", new PlayClickSound(this)); |
|
public void initialize() |
this.getBehavior("changeToMenu").execute(); // load the game menu |
this.getAudioNode(MUSIC).setState(State.PLAYING); |
|
public void update(float deltaTime) |
// Perform the current Running Behavior if the game still running |
if (this.gameState.equals(GameState.RUNNING)) |
this.getBehavior(this.gameState.toString()).execute(deltaTime); |
|
// ⋯ |