summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2020-01-23 17:05:54 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2020-01-23 17:05:54 +0100
commit591ede163eb28e6c74c584503050fda2a419e815 (patch)
tree5fd7b19e8e2fecef1fb017f190036d528b111876
parent416490c4382cfde163be376d978d7890da81bcd5 (diff)
downloadgdx-boardgame-591ede163eb28e6c74c584503050fda2a419e815.zip
gdx-boardgame-591ede163eb28e6c74c584503050fda2a419e815.tar.gz
Board : extends TileKeyGenerator
-rw-r--r--core/src/ch/asynk/gdx/boardgame/boards/Board.java5
-rw-r--r--core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java2
-rw-r--r--core/src/ch/asynk/gdx/boardgame/boards/SquareBoard.java2
-rw-r--r--core/src/ch/asynk/gdx/boardgame/boards/TriangleBoard.java6
-rw-r--r--test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java2
5 files changed, 9 insertions, 8 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/boards/Board.java b/core/src/ch/asynk/gdx/boardgame/boards/Board.java
index b1adf1c..f12391a 100644
--- a/core/src/ch/asynk/gdx/boardgame/boards/Board.java
+++ b/core/src/ch/asynk/gdx/boardgame/boards/Board.java
@@ -2,11 +2,12 @@ package ch.asynk.gdx.boardgame.boards;
import com.badlogic.gdx.math.Vector2;
-public interface Board
+import ch.asynk.gdx.boardgame.TileStorage.TileKeyGenerator;
+
+public interface Board extends TileKeyGenerator
{
public int[] getAngles();
public int size();
- public int getIdx(int x, int y);
public boolean isOnMap(int x, int y);
public void centerOf(int x, int y, Vector2 v);
public void toBoard(float x, float y, Vector2 v);
diff --git a/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java b/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java
index 5d7e401..8ab660b 100644
--- a/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java
+++ b/core/src/ch/asynk/gdx/boardgame/boards/HexBoard.java
@@ -82,7 +82,7 @@ public class HexBoard implements Board
}
}
- @Override public int getIdx(int x, int y)
+ @Override public int genKey(int x, int y)
{
if (!isOnMap(x, y)) return -1;
if (this.orientation == BoardFactory.BoardOrientation.VERTICAL) {
diff --git a/core/src/ch/asynk/gdx/boardgame/boards/SquareBoard.java b/core/src/ch/asynk/gdx/boardgame/boards/SquareBoard.java
index f7df4ff..b9e2426 100644
--- a/core/src/ch/asynk/gdx/boardgame/boards/SquareBoard.java
+++ b/core/src/ch/asynk/gdx/boardgame/boards/SquareBoard.java
@@ -30,7 +30,7 @@ public class SquareBoard implements Board
return angles;
}
- @Override public int getIdx(int x, int y)
+ @Override public int genKey(int x, int y)
{
return (y * cols + x);
}
diff --git a/core/src/ch/asynk/gdx/boardgame/boards/TriangleBoard.java b/core/src/ch/asynk/gdx/boardgame/boards/TriangleBoard.java
index dfbd42d..6cbc69f 100644
--- a/core/src/ch/asynk/gdx/boardgame/boards/TriangleBoard.java
+++ b/core/src/ch/asynk/gdx/boardgame/boards/TriangleBoard.java
@@ -40,9 +40,7 @@ public class TriangleBoard implements Board
this.h43 = this.h * 1.33333f;
}
- // FIXME size() getIdx(int, int)
- @Override public int size() { return 1; }
- @Override public int getIdx(int x, int y) { return -1; }
+ @Override public int size() { return 0; } // FIXME
@Override public int[] getAngles()
{
@@ -53,6 +51,8 @@ public class TriangleBoard implements Board
}
}
+ @Override public int genKey(int x, int y) { return -1; } // FIXME
+
@Override public boolean isOnMap(int x, int y)
{
if (this.orientation == BoardFactory.BoardOrientation.VERTICAL) {
diff --git a/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java b/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java
index 4fb9e6d..0714b8d 100644
--- a/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java
+++ b/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java
@@ -58,7 +58,7 @@ public class BoardScreen extends AbstractScreen
public boolean touch(float x, float y)
{
board.toBoard(x, y, v);
- GdxBoardTest.debug("BoardScreen", String.format("touchDown [%d;%d] => [%d;%d] => %d", (int)x, (int)y, (int)v.x, (int)v.y, board.getIdx((int)v.x, (int)v.y)));
+ GdxBoardTest.debug("BoardScreen", String.format("touchDown [%d;%d] => [%d;%d] => %d", (int)x, (int)y, (int)v.x, (int)v.y, board.genKey((int)v.x, (int)v.y)));
float d0 = board.distance((int)pos.x, (int)pos.y, (int)v.x, (int)v.y, Board.Geometry.TCHEBYCHEV);
float d1 = board.distance((int)pos.x, (int)pos.y, (int)v.x, (int)v.y, Board.Geometry.TAXICAB);
float d2 = board.distance((int)pos.x, (int)pos.y, (int)v.x, (int)v.y, Board.Geometry.EUCLIDEAN);