|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Basic class for representing a physical component of the game
| Method Summary | |
java.awt.Rectangle |
boundingBox()
The area which this GamePiece occupies when drawn at the point (0,0) |
void |
draw(java.awt.Graphics g,
int x,
int y,
java.awt.Component obs,
double zoom)
Draw this GamePiece |
java.lang.String |
getId()
Each GamePiece must have a unique String identifier |
Map |
getMap()
|
java.lang.String |
getName()
The plain English name for this piece |
Stack |
getParent()
|
java.awt.Point |
getPosition()
|
java.lang.Object |
getProperty(java.lang.Object key)
|
java.awt.Shape |
getShape()
The shape of the piece from the user's viewpoint. |
java.lang.String |
getState()
The state information is information that can change during the course of a game. |
java.lang.String |
getType()
The type information is information that does not change during the course of a game. |
Command |
keyEvent(javax.swing.KeyStroke stroke)
Keyboard events are forward to this method when a piece is selected The GamePiece can respond in any way it likes |
void |
setId(java.lang.String id)
|
void |
setMap(Map map)
Each GamePiece belongs to a single Map |
void |
setParent(Stack s)
|
void |
setPosition(java.awt.Point p)
|
void |
setProperty(java.lang.Object key,
java.lang.Object val)
Other properties, possibly game-specific, can be associated with a piece. |
void |
setState(java.lang.String newState)
|
| Method Detail |
public void setMap(Map map)
Mappublic Map getMap()
public void draw(java.awt.Graphics g,
int x,
int y,
java.awt.Component obs,
double zoom)
g - x - x-location of the center of the piecey - y-location of the center of the pieceobs - the Component on which this piece is being drawnzoom - the scaling factor.public java.awt.Point getPosition()
Mappublic void setPosition(java.awt.Point p)
public java.awt.Rectangle boundingBox()
public java.awt.Shape getShape()
boundingBox(), it assumes the position is (0,0) and must be translated
to the actual location where the piece is being drawn.public Stack getParent()
Stack to which this piece belongs, or null if it doesn't belong to a stack.public void setParent(Stack s)
public Command keyEvent(javax.swing.KeyStroke stroke)
Command that, when executed, will invoke
the same response. Usually a ChangePiece command.ForwardToKeyBufferpublic java.lang.String getName()
public java.lang.String getId()
GameState.getNewPieceId()public void setId(java.lang.String id)
public java.lang.String getType()
BasicCommandEncoderpublic java.lang.String getState()
public void setState(java.lang.String newState)
public void setProperty(java.lang.Object key,
java.lang.Object val)
getState() method.public java.lang.Object getProperty(java.lang.Object key)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||