예제 #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
 /* (non-Javadoc)
  * @see java.awt.Canvas#paint(java.awt.Graphics)
  */
 @Override
 public void paint(Graphics g) {
   GamePainters.drawBoard(board, g, this);
   GamePainters.drawEnemies(enemies, g, this);
   GamePainters.drawPlayer(player, g, this);
   GamePainters.paintBottomBar(player, board, g, this);
 }
예제 #3
0
 /* (non-Javadoc)
  * @see java.awt.Canvas#update(java.awt.Graphics)
  */
 @Override
 public void update(Graphics g) {
   GamePainters.updateBoardForEnemies(enemies, board, g, this);
   GamePainters.updateBoardForPlayer(player, board, g, this);
   GamePainters.drawEnemies(enemies, g, this);
   GamePainters.drawPlayer(player, g, this);
   GamePainters.paintBottomBar(player, board, g, this);
 }
예제 #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
  /** Paints "Pause" on the canvas. */
  public void paintPauseScreen() {
    Graphics g = strategy.getDrawGraphics();

    GamePainters.paintPauseScreen(g, this, board);

    strategy.show();
  }
예제 #7
0
  /** Paints "Game Over" on the canvas. */
  public void paintGameOver() {
    Graphics g = strategy.getDrawGraphics();

    GamePainters.paintGameOver(g, this, board);

    strategy.show();
  }
예제 #8
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();
  }