Class Human

java.lang.Object
GamePiece
Human
All Implemented Interfaces:
java.lang.Cloneable

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

    Fields 
    Modifier and Type Field Description
    private int dx
    Human's change in position in the x direction
    private int dy
    Human's change in position in the y direction
    private static int STEP
    Movement default step, in pixels

    Fields inherited from class GamePiece

    char_width, img, img_width, imgDir, xcoord, ycoord
  • Constructor Summary

    Constructors 
    Constructor Description
    Human​(int x, int y, java.awt.Graphics g)
    Create a Human with the given characteristics.
  • Method Summary

    Modifier and Type Method Description
    Human clone()
    Returns a clone of this Human
    int getChangeInX()
    Returns the Human's change in x, in pixels
    int getChangeInY()
    Returns the Human's change in y, in pixels
    void move​(Game game)
    Moves the Human based on the direction specified
    void setDirection​(int horizontalDirection, int verticalDirection)
    Sets which direction Human should go

    Methods inherited from class GamePiece

    draw, getCharacterWidth, getImageWidth, getXPos, getYPos

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • dx

      private int dx
      Human's change in position in the x direction
    • dy

      private int dy
      Human's change in position in the y direction
    • STEP

      private static final int STEP
      Movement default step, in pixels
      See Also:
      Constant Field Values
  • Constructor Details

    • Human

      public Human​(int x, int y, java.awt.Graphics g)
      Create a Human with the given characteristics.
      Parameters:
      x - the x coordinate of where the Human is on the board
      y - the y coordinate of where the Human is on the board
      g - the graphics - where the Human will be displayed
  • Method Details

    • move

      public void move​(Game game)
      Moves the Human based on the direction specified
      Overrides:
      move in class GamePiece
      Parameters:
      game - - provides access to information about the other 'pieces' in the game
    • getChangeInX

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

      public int getChangeInY()
      Returns the Human's change in y, in pixels
      Returns:
      the Human's 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 java.lang.CloneNotSupportedException
      Returns a clone of this Human
      Overrides:
      clone in class GamePiece
      Returns:
      a clone of this Human
      Throws:
      java.lang.CloneNotSupportedException