summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-07 16:35:44 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-07 16:35:44 +0200
commitd5d77c2e64d70c3b6e6228d9b4079e258ad29ffd (patch)
treecf2403a0873fb0da3b87ff95e389e26d3ce4e108 /core/src/ch/asynk/tankontank
parent2895dd0df10da75aad67ec49e5b8999ad69444cd (diff)
downloadRustAndDust-d5d77c2e64d70c3b6e6228d9b4079e258ad29ffd.zip
RustAndDust-d5d77c2e64d70c3b6e6228d9b4079e258ad29ffd.tar.gz
Board: add GridPoint2 setNeighbour(GridPoint2, Orientation, GridPoint2);
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Board.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java
index 0ef2a6e..b74dc87 100644
--- a/core/src/ch/asynk/tankontank/engine/Board.java
+++ b/core/src/ch/asynk/tankontank/engine/Board.java
@@ -151,6 +151,19 @@ public abstract class Board implements Disposable
tiles[5] = getTileSafe((hex.x - 1), (hex.y - 1));
}
+ public GridPoint2 setNeighbour(GridPoint2 hex, Orientation o, GridPoint2 n)
+ {
+ if (o == Orientation.NORTH) n.set((hex.x + 1), hex.y);
+ else if (o == Orientation.NORTH_EAST) n.set(hex.x, (hex.y - 1));
+ else if (o == Orientation.SOUTH_EAST) n.set((hex.x - 1), (hex.y - 1));
+ else if (o == Orientation.SOUTH) n.set((hex.x - 1), hex.y);
+ else if (o == Orientation.SOUTH_WEST) n.set(hex.x, (hex.y + 1));
+ else if (o == Orientation.NORTH_WEST) n.set((hex.x + 1), (hex.y + 1));
+ else n.set(hex.x, hex.y);
+
+ return n;
+ }
+
public float getWidth()
{
return image.getWidth();