|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object robocraft.common.MapLocation
MapLocation is just a wrapper for a pair of integer coordinates that indentify a point on the RoboCraft map. MapLocations are immutable.
Constructor Summary | |
MapLocation(int x_,
int y_)
creates a new MapLocation with the given coordinates. |
Method Summary | |
MapLocation |
add(Direction dir)
returns a new maplocation that is one square in the direction of dir from this. |
Direction |
directionToAdjacent(MapLocation loc)
Return the exact direction towards an adjacent square. |
int |
distanceSquaredTo(MapLocation loc)
|
boolean |
equals(java.lang.Object obj)
two map locations are equal if and only if both their x and y locations are ==. |
int |
hashCode()
|
boolean |
isAdjacentTo(MapLocation loc2)
Determines whether a given maplocation is "adjacent" to this. |
MapLocation |
randomNeighbor()
returns a random neigboring map location l where l.isAdjacentTo(this) |
MapLocation |
subtract(Direction dir)
returns a new maplocation that is one square in the direction opposite of dir from this. |
java.lang.String |
toString()
returns a string representation that looks like [x,y] |
int |
x()
|
int |
y()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public MapLocation(int x_, int y_)
Method Detail |
public int x()
public int y()
public boolean isAdjacentTo(MapLocation loc2)
public java.lang.String toString()
public boolean equals(java.lang.Object obj)
public int hashCode()
public MapLocation randomNeighbor()
public MapLocation add(Direction dir)
public MapLocation subtract(Direction dir)
public int distanceSquaredTo(MapLocation loc)
(this.x - loc.x)^2 + (this.y - loc.y)^2
public Direction directionToAdjacent(MapLocation loc)
loc
- an square adjacent to this
loc
, or
Direction.NONE if loc is not adjacent to this.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |