diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-07 09:33:55 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-07 09:33:55 +0200 |
commit | b2c4097c31c8aa34e0f43f47bf82edfaf5850aec (patch) | |
tree | 229c965de80ac079b13bf341770ddda6534483f6 /core/src/ch/asynk | |
parent | eec5c5a23debb4a9c232a1326a137a727ca5a56a (diff) | |
download | RustAndDust-b2c4097c31c8aa34e0f43f47bf82edfaf5850aec.zip RustAndDust-b2c4097c31c8aa34e0f43f47bf82edfaf5850aec.tar.gz |
Orientation: add Orientation fromAdj(int,int,int,int)
Diffstat (limited to 'core/src/ch/asynk')
-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; + } } |