summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2020-07-08 15:22:17 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2020-07-08 15:22:17 +0200
commitd7013cbbb335c2a70fd6f48a30d0c48b050f4c43 (patch)
tree9b768d2f26f35414d02d92b82df99dea15792a2e /core/src
parente2a7408c96c5f03b81d1250161bdf7310258443f (diff)
downloadgdx-boardgame-d7013cbbb335c2a70fd6f48a30d0c48b050f4c43.zip
gdx-boardgame-d7013cbbb335c2a70fd6f48a30d0c48b050f4c43.tar.gz
HexBoard : fix slope usage on horizontal condition
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java b/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java
index cdae57b..8059362 100644
--- a/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java
+++ b/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java
@@ -23,6 +23,7 @@ public class HexBoard implements Board
private final float dh; // hex top : s/2
private final float h; // square height : s + dh
private final float slope; // dh / dw
+ private final float islope; // dw / dh
private int aOffset; // to fix Orientation computation from adjacents
private int searchCount; // to differentiate move computations
@@ -66,6 +67,8 @@ public class HexBoard implements Board
this.dw = w / 2.0f;
this.dh = side / 2.0f;
this.h = side + dh;
+ this.slope = dh / dw;
+ this.islope = dw / dh;
this.searchCount = 0;
this.stack = new IterableStack<Tile>(10);
@@ -76,14 +79,12 @@ public class HexBoard implements Board
this.cols = cols;
this.rows = rows;
this.aOffset = 0;
- this.slope = dh / dw;
} else {
this.x0 = y0;
this.y0 = x0;
this.cols = rows;
this.rows = cols;
this.aOffset = -60;
- this.slope = dw / dh;
}
this.tl = (2 * this.cols - 1);
@@ -487,7 +488,7 @@ public class HexBoard implements Board
} else {
if (line) {
float k = 0;
- float p = ((o == Orientation.SE || o == Orientation.NW) ? slope : -slope);
+ float p = ((o == Orientation.SE || o == Orientation.NW) ? islope : -islope);
if (o == Orientation.SW || o == Orientation.NW)
k = t.cy - (p * (t.cx + side));
else