|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--nankin.zheng.gatem.util.Position
Logical position of a role on the whole map.
| Field Summary | |
int |
x
|
int |
y
|
| Constructor Summary | |
Position()
Constructor. |
|
Position(int x,
int y)
Constructor, create according to x and y. |
|
| Method Summary | |
java.lang.Object |
clone()
Clone a copy |
int |
distance(Position p)
Calculate the distance between itself and another position. |
boolean |
equals(java.lang.Object p)
Whether equals. |
void |
move(int direction)
move the positon in a given direction |
void |
round(int width,
int height)
Round both its x and its y to the nearest block with the given width and height of the block. |
private int |
roundNumber(int n,
int step)
Round number n to the nearest block whose width is step. |
void |
set(int x,
int y)
Initialize according to coordonates x and y |
void |
set(Position p)
Initialize according to another position |
java.lang.String |
toString()
Convert to String. |
| Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public int x
public int y
| Constructor Detail |
public Position(int x,
int y)
x - x of positiony - y of positionpublic Position()
| Method Detail |
public int distance(Position p)
p - position to calculate the distance, cannot be null
java.lang.NullPointerException - if p is nullpublic void set(Position p)
p - position to be copied, cannot be null
java.lang.NullPointerException - if p is null
public void set(int x,
int y)
x - x of positiony - y of positionpublic void move(int direction)
direction - to move, whose value is defined in class Env
public void round(int width,
int height)
width - width of the blockheight - height of the block
private int roundNumber(int n,
int step)
n - number to be roundedstep - step width of the blockpublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object p)
equals in class java.lang.Objectp - position to be comparedpublic java.lang.Object clone()
clone in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||