diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2020-07-10 20:30:21 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2020-07-10 20:30:21 +0200 |
commit | 9c3a50e677eac6d8df5c5bf1cf88f08ac155ac39 (patch) | |
tree | 838b46c201af42b815fe41493d7c12ff3f597f10 /core | |
parent | ab6e1a0fa330d66ea0ff10460e4557cae2ff1055 (diff) | |
download | gdx-boardgame-9c3a50e677eac6d8df5c5bf1cf88f08ac155ac39.zip gdx-boardgame-9c3a50e677eac6d8df5c5bf1cf88f08ac155ac39.tar.gz |
HexBoard : slope -> m
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java b/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java index b6e342c..54b8268 100644 --- a/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java +++ b/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java @@ -22,8 +22,8 @@ public class HexBoard implements Board private final float dw; // half hex : w/2 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 final float m; // dh / dw + private final float im; // dw / dh private int aOffset; // to fix Orientation computation from adjacents private int searchCount; // to differentiate move computations @@ -67,8 +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.m = dh / dw; + this.im = dw / dh; this.searchCount = 0; this.stack = new IterableStack<Tile>(10); @@ -211,13 +211,12 @@ public class HexBoard implements Board dx -= (col * this.w); // upper left or right rectangle if (dx < this.dw) { - if (dy > (dx * this.slope)) { + if (dy > (dx * this.m)) { // upper left hex row += 1; } } else { - // if (dy > ((2 * this.dh) - (dx * this.slope))) { - if (dy > ((this.w - dx) * this.slope)) { + if (dy > ((this.w - dx) * this.m)) { // upper right hex row += 1; col += 1; @@ -463,7 +462,7 @@ public class HexBoard implements Board v.set(x, from.cy + m * (x - from.cx)); } else { if (line) { - float p = ((o == Orientation.SE || o == Orientation.NW) ? slope : -slope); + float p = ((o == Orientation.SE || o == Orientation.NW) ? m : -m); float k = t.cy - (p * t.cx); if (o == Orientation.SE || o == Orientation.SW) k += side; @@ -491,7 +490,7 @@ public class HexBoard implements Board } else { if (line) { float k = 0; - float p = ((o == Orientation.SE || o == Orientation.NW) ? islope : -islope); + float p = ((o == Orientation.SE || o == Orientation.NW) ? im : -im); if (o == Orientation.SW || o == Orientation.NW) k = t.cy - (p * (t.cx + side)); else |