Package games.stendhal.common
Enum Class Direction
- All Implemented Interfaces:
Serializable,Comparable<Direction>,Constable
a direction to face or walk to
- Author:
- hendrik
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic Directionbuild(int val) converts an integer to a Directionintget()gets the indexstatic DirectiongetAreaDirectionTowardsArea(Rectangle2D area1, Rectangle2D area2) Compares two area and return the direction of area2 towards area1.intgetdx()gets the delta on the x-axisintgetdy()gets the delta on the y-axisabstract Directiongets the next direction clockwiseabstract Directiongets the opposite directionstatic Directionrand()gets a random directionstatic DirectionReturns the enum constant of this class with the specified name.static Direction[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
STOP
do not move -
UP
up, away from the screen -
RIGHT
to the right -
DOWN
down, facing the player -
LEFT
to the left
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
build
converts an integer to a Direction- Parameters:
val- int- Returns:
- Direction
-
getdx
public int getdx()gets the delta on the x-axis- Returns:
- delta x
-
getdy
public int getdy()gets the delta on the y-axis- Returns:
- dy
-
rand
gets a random direction- Returns:
- Direction
-
get
public int get()gets the index- Returns:
- index
-
getAreaDirectionTowardsArea
Compares two area and return the direction of area2 towards area1. So if area2 is left of area1, it will return Direction.LEFT- Parameters:
area1- The area to compare witharea2- The area to be compared- Returns:
- The Direction of area2 as seen from area1
-
oppositeDirection
gets the opposite direction- Returns:
- Direction
-
nextDirection
gets the next direction clockwise- Returns:
- Direction
-