From 88bddf8ebf6bcd3f07535cfe7dd6b562ce330247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 8 Jul 2020 00:52:23 +0200 Subject: HexBoard : fix lineOfSight() --- core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java b/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java index 19a5306..e76b0d0 100644 --- a/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java +++ b/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java @@ -270,10 +270,10 @@ public class HexBoard implements Board v.set(0, 0); // orthogonal projection - int ox0 = x0 - ((y0 + 1) / 2); - int ox1 = x1 - ((y1 + 1) / 2); + float ox0 = x0 - ((y0 + 1) / 2f); + float ox1 = x1 - ((y1 + 1) / 2f); int dy = y1 - y0; - int dx = ox1 - ox0; + float dx = (ox1 - ox0); // quadrant I && III boolean q13 = (((dx >= 0) && (dy >= 0)) || ((dx < 0) && (dy < 0))); @@ -287,15 +287,8 @@ public class HexBoard implements Board // dx counts half width dy = Math.abs(dy); dx = Math.abs(2 * dx); - if ((dy % 2) == 1) { - if ((y0 % 2) == 0) { - dx += xs; - } else { - dx = Math.abs(dx - xs); - } - } - int dx3 = 3 * dx; + int dx3 = (int)(3 * dx); int dy3 = 3 * dy; if (dx == 0 || dx == dy3) @@ -306,7 +299,7 @@ public class HexBoard implements Board int x = x0; int y = y0; - int e = -2 * dx; + int e = (int)(-2 * dx); Tile from = getTile(x0, y0); Tile to = getTile(x1, y1); -- cgit v1.1-2-g2b99