de.adom.jade.world.maps
Class Position

java.lang.Object
  extended by de.adom.jade.world.maps.Position
All Implemented Interfaces:
java.io.Serializable

public class Position
extends java.lang.Object
implements java.io.Serializable

Stores the coordinates of a two dimensional map.

See Also:
Serialized Form

Field Summary
 int x
          the x coordinate of the position
 int y
          the y coordinate of the position
 
Constructor Summary
Position(int xp, int yp)
          Creates a new position.
 
Method Summary
 boolean equals(java.lang.Object o)
          Checks two positions for equality.
 int hashCode()
          Returns the hashcode for this position.
 void moveTowards(Map map, int fromX, int fromY, int toX, int toY)
          Moves this position one step towards a given target position.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

public int x
the x coordinate of the position


y

public int y
the y coordinate of the position

Constructor Detail

Position

public Position(int xp,
                int yp)
Creates a new position.

Parameters:
xp - the x coordinate of the position
yp - the y coordinate of the position
Method Detail

equals

public boolean equals(java.lang.Object o)
Checks two positions for equality.

Overrides:
equals in class java.lang.Object
Parameters:
object - the object to check for equality
Returns:
a boolean value indicating whether both objects are equal

hashCode

public int hashCode()
Returns the hashcode for this position.

Overrides:
hashCode in class java.lang.Object
Returns:
the hashcode of this position

moveTowards

public void moveTowards(Map map,
                        int fromX,
                        int fromY,
                        int toX,
                        int toY)
Moves this position one step towards a given target position.

Parameters:
fromX - the x coordinate of the start position
fromY - the y coordinate of the start position
toX - the x coordinate of the target position
toY - the y coordinate of the target position