コード例 #1
0
  /**
   * Creates a new "game" from the current engine.Globals.game variable. While the ANN stays the
   * same, the speed, actor positions, score, et cetera, are all reset.
   */
  public void newGame() {
    stopped = true;
    player.setLives(STARTING_LIVES);
    player.setScore(0);
    Graphics g = strategy.getDrawGraphics();
    waiting = true;

    Globals.state = ENEMY_HUNTER_STATE;

    player.setCenter(board.getPlayerStartPoint());
    player.setDirection(Player.DEFAULT_STARTING_DIRECTION);

    board.reset();
    Globals.blipsLeft = Globals.game.getBoard().getBlipCount();

    for (Enemy enemy : enemies) {
      enemy.reset();
    }

    GamePainters.drawBoard(board, g, this);
    GamePainters.drawEnemies(enemies, g, this);
    GamePainters.drawPlayer(player, g, this);
    GamePainters.paintBottomBar(player, board, g, this);
    strategy.show();
  }
コード例 #2
0
  /**
   * Causes the ghosts and player to go back to their original starting positions. Used when a
   * player dies, for example.
   */
  public void resetCanvas() {
    Graphics g = strategy.getDrawGraphics();
    waiting = true;

    Globals.state = ENEMY_HUNTER_STATE;

    player.setCenter(board.getPlayerStartPoint());
    player.setDirection(Player.DEFAULT_STARTING_DIRECTION);

    for (Enemy enemy : enemies) {
      enemy.reset();
    }

    GamePainters.drawBoard(board, g, this);
    GamePainters.drawEnemies(enemies, g, this);
    GamePainters.drawPlayer(player, g, this);
    GamePainters.paintBottomBar(player, board, g, this);
    strategy.show();
  }