summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-07 09:33:55 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-07 09:33:55 +0200
commitb2c4097c31c8aa34e0f43f47bf82edfaf5850aec (patch)
tree229c965de80ac079b13bf341770ddda6534483f6 /core/src/ch
parenteec5c5a23debb4a9c232a1326a137a727ca5a56a (diff)
downloadRustAndDust-b2c4097c31c8aa34e0f43f47bf82edfaf5850aec.zip
RustAndDust-b2c4097c31c8aa34e0f43f47bf82edfaf5850aec.tar.gz
Orientation: add Orientation fromAdj(int,int,int,int)
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Orientation.java27
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;
+ }
}