diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/src/ch/asynk/tankontank/engine/Orientation.java | 27 | 
1 files changed, 27 insertions, 0 deletions
| diff --git a/core/src/ch/asynk/tankontank/engine/Orientation.java b/core/src/ch/asynk/tankontank/engine/Orientation.java index 580c4d2..10fa441 100644 --- a/core/src/ch/asynk/tankontank/engine/Orientation.java +++ b/core/src/ch/asynk/tankontank/engine/Orientation.java @@ -98,4 +98,31 @@ public enum Orientation              return NORTH_EAST;          }      } + +    public static Orientation fromAdj(int col0, int row0, int col1, int row1) +    { +        Orientation o = KEEP; +        if (row1 == row0) { +            if (col1 == (col0 - 1)) { +                o = SOUTH; +            } else if (col1 == (col0 + 1)) { +                o = NORTH; +            } +        } else if (row1 == (row0 - 1)) { +            if (col1 == (col0 - 1)) { +                o = SOUTH_EAST; +            } else if (col1 == col0) { +                o = NORTH_EAST; +            } + +        } else if (row1 == (row0 + 1)) { +            if (col1 == col0) { +                o = SOUTH_WEST; +            } else if (col1 == (col0 + 1)) { +                o = NORTH_WEST; +            } +        } + +        return o; +    }  } | 
