summaryrefslogtreecommitdiffstats
path: root/test/src/ch/asynk/gdx
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2020-01-21 09:31:16 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2020-01-21 09:31:16 +0100
commit3a153fe86fcd3ae224b7c6ddba1780eeed89ec8a (patch)
treea9ee37d934a8885c83e3398dd3dc03e943da5320 /test/src/ch/asynk/gdx
parent5297877a607167c991364493f3e7fd283d1ead17 (diff)
downloadgdx-boardgame-3a153fe86fcd3ae224b7c6ddba1780eeed89ec8a.zip
gdx-boardgame-3a153fe86fcd3ae224b7c6ddba1780eeed89ec8a.tar.gz
Board : add boolean isOnBoard(int, int)
Diffstat (limited to 'test/src/ch/asynk/gdx')
-rw-r--r--test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java2
-rw-r--r--test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java24
2 files changed, 14 insertions, 12 deletions
diff --git a/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java b/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java
index 6fcc30f..0990d7b 100644
--- a/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java
+++ b/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java
@@ -41,7 +41,7 @@ public class AnimationsScreen extends AbstractScreen
super(app, "");
this.map = app.assets.getTexture(app.assets.MAP_00);
- this.board = BoardFactory.getBoard(BoardFactory.BoardType.HEX, 110, 50, 103, BoardFactory.BoardOrientation.VERTICAL);
+ this.board = BoardFactory.getBoard(0, 0, BoardFactory.BoardType.HEX, 110, 50, 103, BoardFactory.BoardOrientation.VERTICAL);
this.camera = this.cam = new Camera(10, map.getWidth(), map.getHeight(), 1.0f, 0.3f, false);
this.panzer = getPiece(app, 7, 4, Orientation.NW, app.assets.PANZER, 1f);
diff --git a/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java b/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java
index f609f2c..37fdade 100644
--- a/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java
+++ b/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java
@@ -61,12 +61,14 @@ public class BoardScreen extends AbstractScreen
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);
- GdxBoardTest.debug("BoardScreen", String.format(" from [%d;%d] => %d :: %d :: %f", (int)pos.x, (int)pos.y, (int)d0, (int)d1, d2));
- pos.set(v);
- board.centerOf((int)v.x, (int)v.y, v);
- panzer.centerOn(v.x, v.y);
- panzer.setRotation(Orientation.fromR(panzer.getRotation()).left().r());
- GdxBoardTest.debug("BoardScreen", String.format(" => [%d;%d]", (int)v.x, (int)v.y));
+ if (board.isOnMap((int)v.x, (int)v.y)) {
+ GdxBoardTest.debug("BoardScreen", String.format(" from [%d;%d] => %d :: %d :: %f", (int)pos.x, (int)pos.y, (int)d0, (int)d1, d2));
+ pos.set(v);
+ board.centerOf((int)v.x, (int)v.y, v);
+ panzer.centerOn(v.x, v.y);
+ panzer.setRotation(Orientation.fromR(panzer.getRotation()).left().r());
+ GdxBoardTest.debug("BoardScreen", String.format(" => [%d;%d]", (int)v.x, (int)v.y));
+ }
return true;
}
@@ -78,7 +80,7 @@ public class BoardScreen extends AbstractScreen
dy = 0;
w = map.getWidth();
h = map.getHeight();
- board = BoardFactory.getBoard(BoardFactory.BoardType.HEX, 110, 50, 103, BoardFactory.BoardOrientation.VERTICAL);
+ board = BoardFactory.getBoard(10, 9, BoardFactory.BoardType.HEX, 110, 50, 103, BoardFactory.BoardOrientation.VERTICAL);
}
public void setHEX_H()
@@ -89,7 +91,7 @@ public class BoardScreen extends AbstractScreen
dy = - dx;
w = map.getHeight();
h = map.getWidth();
- board = BoardFactory.getBoard(BoardFactory.BoardType.HEX, 110, 103, 50, BoardFactory.BoardOrientation.HORIZONTAL);
+ board = BoardFactory.getBoard(9, 10, BoardFactory.BoardType.HEX, 110, 103, 50, BoardFactory.BoardOrientation.HORIZONTAL);
}
public void setSQUARE()
@@ -100,7 +102,7 @@ public class BoardScreen extends AbstractScreen
dy = 0;
w = map.getWidth();
h = map.getHeight();
- board = BoardFactory.getBoard(BoardFactory.BoardType.SQUARE, 83, 5, 5);
+ board = BoardFactory.getBoard(8, 8, BoardFactory.BoardType.SQUARE, 83, 5, 5);
}
public void setTRI_H()
@@ -111,7 +113,7 @@ public class BoardScreen extends AbstractScreen
dy = 0;
w = map.getWidth();
h = map.getHeight();
- board = BoardFactory.getBoard(BoardFactory.BoardType.TRIANGLE, 150, 109, 53, BoardFactory.BoardOrientation.HORIZONTAL);
+ board = BoardFactory.getBoard(21, 8, BoardFactory.BoardType.TRIANGLE, 150, 109, 53, BoardFactory.BoardOrientation.HORIZONTAL);
}
public void setTRI_V()
@@ -122,7 +124,7 @@ public class BoardScreen extends AbstractScreen
dy = - dx;
w = map.getHeight();
h = map.getWidth();
- board = BoardFactory.getBoard(BoardFactory.BoardType.TRIANGLE, 150, 16, 110, BoardFactory.BoardOrientation.VERTICAL);
+ board = BoardFactory.getBoard(8, 21, BoardFactory.BoardType.TRIANGLE, 150, 16, 110, BoardFactory.BoardOrientation.VERTICAL);
}
}