diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2020-07-08 00:52:23 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2020-07-08 00:52:23 +0200 |
commit | 88bddf8ebf6bcd3f07535cfe7dd6b562ce330247 (patch) | |
tree | e6ecbd182fd277272b2d5a543665da2f900c7831 /core/src/ch/asynk/gdx/boardgame | |
parent | 6495a1d83bbd409930fe6b80eeb4164c6299694d (diff) | |
download | gdx-boardgame-88bddf8ebf6bcd3f07535cfe7dd6b562ce330247.zip gdx-boardgame-88bddf8ebf6bcd3f07535cfe7dd6b562ce330247.tar.gz |
HexBoard : fix lineOfSight()
Diffstat (limited to 'core/src/ch/asynk/gdx/boardgame')
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java | 17 |
1 files 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); |