|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectwyvern.kernel.properties.PList
wyvern.kernel.maps.MapObject
wyvern.lib.classes.games.Checkers
This class implements a 2-player checkers game with human-sized pieces. When placed in a map at location (x,y), it treats (x,y) as its upper-left corner, creates an 8x8 checkerboard, and populates it with pieces. It also creates 2 "thrones" for players to sit in and begin a game.
| Field Summary | |
static int |
KING
|
static int |
PIECE
|
static java.lang.String[] |
titles
|
| Fields inherited from class wyvern.kernel.maps.MapObject |
IN_MAP_EDITOR, listenerList_ |
| Fields inherited from class wyvern.kernel.properties.PList |
readOnly_ |
| Fields inherited from interface wyvern.lib.PropertyList |
PROPERTY_PACKAGE |
| Constructor Summary | |
Checkers()
|
|
| Method Summary | |
Point |
boardToMap(int x,
int y)
Returns a point in board coordinates. |
Point |
boardToMap(Point p)
Returns a point in board coordinates. |
void |
checkKing(Commandable agent,
wyvern.lib.classes.games.Checkers.Piece p)
Possibly turns a piece into a King after a move. |
boolean |
doMove(Commandable agent,
Point dest)
Attempts the move. |
Rectangle |
getBounds()
Returns the bounds of the board object. |
int[] |
getImageDescriptors()
Returns the board's appearance. |
wyvern.lib.classes.games.Checkers.Piece |
getPiece(int x,
int y)
Returns the checkers piece at the specified board location. |
wyvern.lib.classes.games.Checkers.Piece |
getPiece(Point loc)
Returns the checkers piece at the specified map location. |
int |
getTile(int xloc,
int yloc)
Overrides MapObject.getTile(). |
void |
handleMouse(Commandable agent,
Point click)
Moves a piece. |
void |
initialize()
Adds checkers-specific properties. |
void |
initPieces()
Creates all the pieces and sets them in their starting places. |
boolean |
isEmpty(int x,
int y)
Returns true if the specified board location is empty. |
boolean |
isEmpty(Point p)
Returns true if the specified board location is empty. |
Point |
mapToBoard(int x,
int y)
Returns a point in board coordinates. |
Point |
mapToBoard(Point p)
Returns a point in board coordinates. |
void |
mouseClicked(MouseCommandEvent event)
Handles a mouse-click. |
void |
restart()
Clears the current game and starts over. |
void |
setMap(GameMap map,
int x,
int y)
Sets the checkers board in the map. |
void |
trySelection(Commandable agent,
Point click)
Attempts to select a game piece for moving. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int PIECE
public static final int KING
public static final java.lang.String[] titles
| Constructor Detail |
public Checkers()
| Method Detail |
public void initialize()
initialize in interface GameObjectinitialize in class MapObject
public void setMap(GameMap map,
int x,
int y)
setMap in interface GameObjectsetMap in class MapObjectpublic int[] getImageDescriptors()
getImageDescriptors in interface GameObjectgetImageDescriptors in class MapObject
public int getTile(int xloc,
int yloc)
getTile in interface GameObjectgetTile in class MapObjectpublic Rectangle getBounds()
getBounds in interface GameObjectgetBounds in class MapObjectpublic void initPieces()
public Point mapToBoard(Point p)
public Point mapToBoard(int x,
int y)
public Point boardToMap(int x,
int y)
public Point boardToMap(Point p)
public void mouseClicked(MouseCommandEvent event)
mouseClicked in interface MouseInterestevent - the mouse event
public void handleMouse(Commandable agent,
Point click)
agent - the player doing the moveclick - the point where they clicked, in map coordinatespublic wyvern.lib.classes.games.Checkers.Piece getPiece(Point loc)
loc - the board position (in MAP coordinates, not board coords)
public wyvern.lib.classes.games.Checkers.Piece getPiece(int x,
int y)
x - the board x position in BOARD coordinatesy - the board y position in BOARD coordinates
public boolean isEmpty(int x,
int y)
x - the x position in BOARD coordinates, where the
upper-left corner (black queen's rook) is (0, 0).y - the y position in BOARD coordinatespublic boolean isEmpty(Point p)
p - the x,y position in BOARD coordinates, where the
upper-left corner of the board is (0,0).
public void trySelection(Commandable agent,
Point click)
public boolean doMove(Commandable agent,
Point dest)
agent - the agent doing the movedest - the proposed destination for the move, in map coords
public void checkKing(Commandable agent,
wyvern.lib.classes.games.Checkers.Piece p)
agent - the playerp - the piecepublic void restart()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||