예제 #1
0
 public void restart() {
   currentState = GameState.READY;
   guy.restart();
   scrollHandler.restart();
   for (int i = 0; i < enemyList.size(); i++) {
     enemyList.get(i).restart();
   }
   for (int i = 0; i < tileList.size(); i++) {
     tileList.get(i).restart();
   }
 }
예제 #2
0
  public void updateRunning(float delta) {
    guy.update(delta);
    for (int i = 0; i < enemyList.size(); i++) {
      enemyList.get(i).update(delta, gameWidth);
    }
    for (int i = 0; i < tileList.size(); i++) {
      tileList.get(i).update(delta);
    }
    scrollHandler.update(delta);

    checkIfGameWon();
    checkIfAlive();
    handleCollisions();
  }
예제 #3
0
 private void checkIfAlive() {
   if (!getGuy().isAlive()) {
     scrollHandler.stop();
     currentState = GameState.GAMEOVER;
   }
 }
예제 #4
0
 public void start() {
   currentState = GameState.RUNNING;
   scrollHandler.start();
 }
예제 #5
0
 private void checkIfGameWon() {
   if (getGuy().isGameWon()) {
     scrollHandler.stop();
     currentState = GameState.WINNER;
   }
 }