Class Human

All Implemented Interfaces:
Cloneable

class Human extends GamePiece
Represents a Human in the Game
  • Field Details

    • dx

      private int dx
    • dy

      private int dy
    • STEP

      private static final int STEP
      See Also:
  • Constructor Details

    • Human

      public Human(int x, int y, Graphics g)
      Creates the Human at the given x and y coordinates.
      Parameters:
      x - the x-coordinate of the game piece
      y - the y-coordinate of the game piece
      g - the Graphics object used to draw the game piece's image
  • Method Details

    • takeTurn

      public void takeTurn(Game game)
      Human takes turn, moving based on its current direction
      Overrides:
      takeTurn in class GamePiece
      Parameters:
      game - - the game that contains this game piece (and others)
    • getChangeInX

      public int getChangeInX()
      Returns this Human's change in the x direction, in pixels
      Returns:
      the change in x, in pixels
    • getChangeInY

      public int getChangeInY()
      Returns this Human's change in the y direction, in pixels
      Returns:
      the change in y, in pixels
    • setDirection

      public void setDirection(int horizontalDirection, int verticalDirection)
      Sets which direction Human should go
      Parameters:
      horizontalDirection - : -1 means left, 1 means right, 0 means no horizontal movement
      verticalDirection - : -1 means up, 1 means down, 0 means no vertical movement
    • clone

      public Human clone() throws CloneNotSupportedException
      Returns a clone of this Human
      Overrides:
      clone in class GamePiece
      Throws:
      CloneNotSupportedException