|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IPlayField
Read-only interface to the play field.
Playfields use a 2D coordinate system. X-values increase from left to right, and Y-values increase from top to bottom.
0----------------->x | ^ | -y | <-x +x> | +y | v | v y
This interface is not meant to be implemented by user classes. It is mainly intended to provide access to the field provided by the framework. If you want to make your own field class, you may consider making a different interface.
It is usually enough to use the various convenience methods provided for interacting with the field, but the below explanation may be useful in some cases.
Objects on the playfield are identified by integer codes. getObjectAt(x, y) obtains the object at a given position. This object can be either a coin (FIELD_COIN), a wall (FIELD_WALL), or an empty square (FIELD_FREE). Only FIELD_FREE and FIELD_COIN are safe to pass through.
In addition, the object can be the trail of an enemy tron. AbstractPlayer.getTrailIdOf(id) gets the trail code for the player identified by "id". Id numbers range from 0 and upwards. getTrons() in this class can be used to get all trons, and then getId() can be used on each to obtain their id code. BasePlayer.getEnemyIds() can also be used to obtain enemy tron ids.
AbstractPlayer
,
BasePlayer
,
ITron
Field Summary | |
---|---|
static int |
FIELD_COIN
A coin. |
static int |
FIELD_FREE
An empty square. |
static int |
FIELD_WALL
A wall. |
Method Summary | |
---|---|
int |
getHeight()
Obtain the height (in units) of the field |
int |
getNumOfPlayers()
Get the number of players in the play field. |
int |
getObjectAt(int x,
int y)
Obtain Object ID at a certain position in the field. |
int |
getRemainingRounds()
Return remaining rounds in this match. |
int |
getRemainingTurns()
Return remaining turns in this round. |
int |
getRound()
Return number of current round. |
java.util.Vector<ITron> |
getTrons()
Obtain Trons on this playfield. |
int |
getTurn()
Return number of current turn. |
int |
getWidth()
Obtain the width (in units) of the field |
int[] |
stepOne(int x,
int y,
FieldDirection dir)
Return the new coordinates of the tron after stepping one step. |
Field Detail |
---|
static final int FIELD_FREE
static final int FIELD_WALL
static final int FIELD_COIN
Method Detail |
---|
int getWidth()
int getHeight()
int getObjectAt(int x, int y)
x
- y
-
java.util.Vector<ITron> getTrons()
int[] stepOne(int x, int y, FieldDirection dir)
x
- Current position Xy
- Current position Ydir
- Direction to step in
int getNumOfPlayers()
int getTurn()
int getRound()
int getRemainingTurns()
int getRemainingRounds()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |