コード例 #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
  /** Paints "Pause" on the canvas. */
  public void paintPauseScreen() {
    Graphics g = strategy.getDrawGraphics();

    GamePainters.paintPauseScreen(g, this, board);

    strategy.show();
  }
コード例 #3
0
  /** Paints "Game Over" on the canvas. */
  public void paintGameOver() {
    Graphics g = strategy.getDrawGraphics();

    GamePainters.paintGameOver(g, this, board);

    strategy.show();
  }
コード例 #4
0
  /** Replaces the current player icon with one showing that the player has died. */
  public void paintDeadPlayer() {
    Graphics g = strategy.getDrawGraphics();

    GamePainters.drawBoard(board, g, this);
    GamePainters.drawDeadPlayer(player, g, this);

    strategy.show();
  }
コード例 #5
0
  /** Updates the canvas. */
  public void update() {
    Graphics g = strategy.getDrawGraphics();

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

    strategy.show();
  }
コード例 #6
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();
  }