51 lines
1.1 KiB
Java
51 lines
1.1 KiB
Java
|
package build.com.hobogames;
|
||
|
|
||
|
import build.com.hobogames.states.*;
|
||
|
|
||
|
public class Game {
|
||
|
|
||
|
private boolean gameOn;
|
||
|
|
||
|
private Handler handler;
|
||
|
private State menuState;
|
||
|
private State playState;
|
||
|
|
||
|
public Game() {
|
||
|
|
||
|
}
|
||
|
|
||
|
public void init() {
|
||
|
gameOn = true;
|
||
|
|
||
|
handler = new Handler(this);
|
||
|
menuState = new MenuState(handler);
|
||
|
playState = new PlayState(handler);
|
||
|
State.setCurrentState(menuState);
|
||
|
State.getCurrentState().init();
|
||
|
|
||
|
}
|
||
|
|
||
|
public void gameLoop() {
|
||
|
init();
|
||
|
|
||
|
while (gameOn) {
|
||
|
if (State.getCurrentState() != null) {
|
||
|
State.getCurrentState().update();
|
||
|
}
|
||
|
System.out.println("\n----------------\n");
|
||
|
|
||
|
}
|
||
|
|
||
|
end();
|
||
|
}
|
||
|
|
||
|
public void end() {
|
||
|
System.out.println("Exiting game.");
|
||
|
}
|
||
|
|
||
|
public boolean getGameOn() {return gameOn;}
|
||
|
public MenuState getMenuState() {return (MenuState)menuState;}
|
||
|
public PlayState getPlayState() {return (PlayState)playState;}
|
||
|
|
||
|
public void setGameOn(boolean gameOn) {this.gameOn = gameOn;}
|
||
|
}
|