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
-
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 Humanint
getChangeInX()
Returns the Human's change in x, in pixelsint
getChangeInY()
Returns the Human's change in y, in pixelsvoid
move(Game game)
Moves the Human based on the direction specifiedvoid
setDirection(int horizontalDirection, int verticalDirection)
Sets which direction Human should go
-
Field Details
-
dx
private int dxHuman's change in position in the x direction -
dy
private int dyHuman's change in position in the y direction -
STEP
private static final int STEPMovement 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 boardy
- the y coordinate of where the Human is on the boardg
- the graphics - where the Human will be displayed
-
-
Method Details
-
move
Moves the Human based on the direction specified -
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 movementverticalDirection
- : -1 means up, 1 means down, 0 means no vertical movement
-
clone
Returns a clone of this Human
-