com.aranai.dungeonator
Class Direction

java.lang.Object
  extended by com.aranai.dungeonator.Direction

public final class Direction
extends java.lang.Object

Specifies byte values for the 12 cardinal directions, starting at 0 for North and proceeding clockwise. Also includes convenience arrays and functions for determining side from direction, directions from side, and computing rotations.


Field Summary
static byte[] CARDINALS
          Cardinal Directions
static byte CLOCKWISE
          Clockwise Direction Sequence
static byte COUNTER_CLOCKWISE
          Counter-Clockwise Direction Sequence
static byte E
          East
static byte ENE
          East by Northeast
static byte ESE
          East by Southeast
static byte N
          North
static byte NNE
          North by Northeast
static byte NNW
          North by Northwest
static byte S
          South
static byte[] SIDE_EAST
          East Side Directions
static byte[] SIDE_NORTH
          North Side Directions
static byte[] SIDE_SOUTH
          South Side Directions
static byte[] SIDE_WEST
          West Side Directions
static byte SSE
          South by Southeast
static byte SSW
          South by Southwest
static byte W
          West
static byte WNW
          West by Northwest
static byte WSW
          West by Southwest
 
Constructor Summary
Direction()
           
 
Method Summary
static byte[] getSideFromDirection(byte direction)
          Gets the side to which the specified direction belongs.
static byte rotate(byte start, byte direction, int advance)
          Return a direction rotated a specified number of steps, either clockwise or counterclockwise, from a specified starting direction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

N

public static byte N
North


E

public static byte E
East


S

public static byte S
South


W

public static byte W
West


NNE

public static byte NNE
North by Northeast


ENE

public static byte ENE
East by Northeast


ESE

public static byte ESE
East by Southeast


SSE

public static byte SSE
South by Southeast


SSW

public static byte SSW
South by Southwest


WSW

public static byte WSW
West by Southwest


WNW

public static byte WNW
West by Northwest


NNW

public static byte NNW
North by Northwest


SIDE_NORTH

public static byte[] SIDE_NORTH
North Side Directions


SIDE_EAST

public static byte[] SIDE_EAST
East Side Directions


SIDE_SOUTH

public static byte[] SIDE_SOUTH
South Side Directions


SIDE_WEST

public static byte[] SIDE_WEST
West Side Directions


CARDINALS

public static byte[] CARDINALS
Cardinal Directions


CLOCKWISE

public static byte CLOCKWISE
Clockwise Direction Sequence


COUNTER_CLOCKWISE

public static byte COUNTER_CLOCKWISE
Counter-Clockwise Direction Sequence

Constructor Detail

Direction

public Direction()
Method Detail

getSideFromDirection

public static byte[] getSideFromDirection(byte direction)
Gets the side to which the specified direction belongs.

Parameters:
direction - the direction
Returns:
the side the direction belongs to

rotate

public static byte rotate(byte start,
                          byte direction,
                          int advance)
Return a direction rotated a specified number of steps, either clockwise or counterclockwise, from a specified starting direction.

Parameters:
start - the starting direction
direction - the direction to rotate
advance - the number of steps to advance
Returns:
the resulting direction, or -1 if the input is invalid