diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2020-07-08 13:26:53 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2020-07-08 13:26:53 +0200 |
commit | ec856947b9b82ff7c4678a37b8246f9907cac284 (patch) | |
tree | 6f4ae8531ea74a3a4c8a20dbdd6d1165880d9f54 /core/src/ch/asynk | |
parent | 97b9ff462337a1888f0e7cc1e6092e290c2112a9 (diff) | |
download | gdx-boardgame-ec856947b9b82ff7c4678a37b8246f9907cac284.zip gdx-boardgame-ec856947b9b82ff7c4678a37b8246f9907cac284.tar.gz |
HexBoard : shorten contact point computation
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java b/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java index f22b824..35bfac5 100644 --- a/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java +++ b/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java @@ -453,23 +453,20 @@ public class HexBoard implements Board v.set(t.cx, t.cy + side); } else if (o == Orientation.E) { float x = t.cx - dw; - float y = from.cy + m * (x - from.cx); - v.set(x, y); + v.set(x, from.cy + m * (x - from.cx)); } else if (o == Orientation.W) { float x = t.cx + dw; - float y = from.cy + m * (x - from.cx); - v.set(x, y); + v.set(x, from.cy + m * (x - from.cx)); } else { if (line) { - float k = 0; float p = ((o == Orientation.SE || o == Orientation.NW) ? slope : -slope); + float k = t.cy - (p * t.cx); if (o == Orientation.SE || o == Orientation.SW) - k = (t.cy + side) - (p * t.cx); + k += side; else - k = (t.cy - side) - (p * t.cx); + k -= side; float x = (k - c) / (m - p); - float y = m * x + c; - v.set(x, y); + v.set(x, m * x + c); } else { float x = t.cx + ((o == Orientation.NE || o == Orientation.SE) ? -dw : dw); float y = t.cy + ((o == Orientation.SE || o == Orientation.SW) ? dh : -dh); @@ -483,12 +480,10 @@ public class HexBoard implements Board v.set(t.cx + side, t.cy); } else if (o == Orientation.N) { float y = t.cy - dw; - float x = from.cx + (y - from.cy) / m; - v.set(x, y); + v.set(from.cx + (y - from.cy) / m, y); } else if (o == Orientation.S) { float y = t.cy + dw; - float x = from.cx + (y - from.cy) / m; - v.set(x, y); + v.set(from.cx + (y - from.cy) / m, y); } else { if (line) { float k = 0; @@ -498,8 +493,7 @@ public class HexBoard implements Board else k = t.cy - (p * (t.cx - side)); float x = (k - c) / (m - p); - float y = m * x + c; - v.set(x, y); + v.set(x, m * x + c); } else { float x = t.cx + ((o == Orientation.NW || o == Orientation.SW) ? dh: -dh); float y = t.cy + ((o == Orientation.SE || o == Orientation.SW) ? dw : -dw); |