Class GamePiece
java.lang.Object
GamePiece
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
Human
The base class for GamePieces that are displayed on the game panel.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a clone of this GamePiecevoid
draw()
Draws the GamePiece on the canvasint
Returns the width of the game piece's character (not necessarily the same as the image's width).int
Returns the width of the game piece's imageint
getXPos()
Returns the game piece's x coordinateint
getYPos()
Returns the game piece's y coordinatevoid
The GamePiece takes its turn (nothing for this class)
-
Field Details
-
img
-
xcoord
protected int xcoord -
ycoord
protected int ycoord -
img_width
protected int img_widthsize of the image -
char_width
protected int char_widthsize of the character inside the image -
brush
-
imgDir
Location of the image files. When using Eclipse, use bin/. Without Eclipse structure, use ./
-
-
Constructor Details
-
GamePiece
Creates a GamePiece at the given x and y coordinates.- Parameters:
x
- the x-coordinate of the game piecey
- the y-coordinate of the game pieceg
- the Graphics object used to draw the game piece's image
-
-
Method Details
-
getXPos
public int getXPos()Returns the game piece's x coordinate -
getYPos
public int getYPos()Returns the game piece's y coordinate -
getImageWidth
public int getImageWidth()Returns the width of the game piece's image -
getCharacterWidth
public int getCharacterWidth()Returns the width of the game piece's character (not necessarily the same as the image's width). -
draw
public void draw()Draws the GamePiece on the canvas -
takeTurn
The GamePiece takes its turn (nothing for this class)- Parameters:
game
- - the game that contains this game piece (and others)
-
clone
Returns a clone of this GamePiece- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-