diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2020-06-18 12:40:58 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2020-06-18 12:40:58 +0200 |
commit | 064aab5464be96505bcab4a09673492192a3c2aa (patch) | |
tree | 7ebb95e7eaaf44fcc9e2e05bd94a5e49f1ac07c0 /core | |
parent | 719af71b4c927aa31d665c2e02de6da90fcab028 (diff) | |
download | gdx-boardgame-064aab5464be96505bcab4a09673492192a3c2aa.zip gdx-boardgame-064aab5464be96505bcab4a09673492192a3c2aa.tar.gz |
HexBoard : fix slope definition
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java b/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java index 1ee05ea..785da0e 100644 --- a/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java +++ b/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java @@ -70,7 +70,6 @@ public class HexBoard implements Board this.dw = w / 2.0f; this.dh = side / 2.0f; this.h = side + dh; - this.slope = dh / dw; this.searchCount = 0; this.stack = new IterableStack<Tile>(10); @@ -78,9 +77,11 @@ public class HexBoard implements Board if (this.orientation == BoardFactory.BoardOrientation.VERTICAL) { this.aOffset = 0; this.tl = (2 * cols - 1); + this.slope = dh / dw; } else { this.aOffset = -60; this.tl = (2 * rows - 1); + this.slope = dw / dh; } this.adjacents = new Tile[6]; @@ -223,14 +224,14 @@ public class HexBoard implements Board dx -= ((col * this.h) + this.side); dy -= (row * this.w); // upper or lower rectangle - if (dy > ((this.dw - dx) / this.slope)) { - if (dy > ((2 * this.dw) - (dx / this.slope))) { + if (dy > ((this.dw - dx) * this.slope)) { + if (dy > ((2 * this.dw) - (dx * this.slope))) { // upper right hex col += 1; row += 1; } } else { - if (dy < (dx / this.slope)) { + if (dy < (dx * this.slope)) { // lower right hex col += 1; } |