Enum Class MovementDirection

java.lang.Object
java.lang.Enum<MovementDirection>
mazealgo.viewmodel.MovementDirection
All Implemented Interfaces:
Serializable, Comparable<MovementDirection>, Constable

public enum MovementDirection extends Enum<MovementDirection>
The eight directions a player can move in a 2D maze, mapped to the numeric keypad layout so the controller can dispatch a NumPad key straight to a direction without a switch:
      7  8  9
       \ | /
      4 -+- 6     (5 has no movement)
       / | \
      1  2  3
 
Diagonal moves carry the diagonal flag so the ViewModel can apply the pinhole rule (a diagonal step is only legal if at least one of the two adjacent orthogonal cells around the corner is also passable — same rule used by SearchableMaze).
  • Enum Constant Details

  • Field Details

    • dr

      public final int dr
    • dc

      public final int dc
    • diagonal

      public final boolean diagonal
  • Method Details

    • values

      public static MovementDirection[] 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

      public static MovementDirection valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • forNumpadDigit

      public static MovementDirection forNumpadDigit(int digit)
      Maps a NumPad key (KeyCode.NUMPAD1..9) by its digit. Returns null for 5.