getAngleByDirectional method

double getAngleByDirectional(
  1. Direction direction
)

Implementation

double getAngleByDirectional(Direction direction) {
  switch (direction) {
    case Direction.left:
      return 180 / PI_180;
    case Direction.right:
      // we can't use 0 here because then no movement happens
      // we're just going as close to 0.0 without being exactly 0.0
      // if you have a better idea. Please be my guest
      return 0.0000001 / PI_180;
    case Direction.up:
      return -90 / PI_180;
    case Direction.down:
      return 90 / PI_180;
    case Direction.upLeft:
      return -135 / PI_180;
    case Direction.upRight:
      return -45 / PI_180;
    case Direction.downLeft:
      return 135 / PI_180;
    case Direction.downRight:
      return 45 / PI_180;
    default:
      return 0;
  }
}