summaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2019-12-03 11:46:36 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2019-12-03 11:46:36 +0100
commite3cd5c9c5ddba426f725a4ba6c64b59fc4db9718 (patch)
tree9aa8976cd8f20e4ba0c1074ad5f81dbc80d0af3c /test/src
parent5b60a935ad1f82ae08c936df5e1e9b2c7c709de7 (diff)
downloadgdx-boardgame-e3cd5c9c5ddba426f725a4ba6c64b59fc4db9718.zip
gdx-boardgame-e3cd5c9c5ddba426f725a4ba6c64b59fc4db9718.tar.gz
Board : implements distance for Hex and Square boards
Diffstat (limited to 'test/src')
-rw-r--r--test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java b/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java
index 613fe57..85b57c9 100644
--- a/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java
+++ b/test/src/ch/asynk/gdx/boardgame/test/BoardScreen.java
@@ -21,6 +21,7 @@ public class BoardScreen extends AbstractScreen
{
private final Assets assets;
private final Piece panzer;
+ private final Vector2 pos;
private final Vector2 v;
public Texture map;
public Board board;
@@ -33,6 +34,7 @@ public class BoardScreen extends AbstractScreen
public MyBoard(final Assets assets)
{
this.assets = assets;
+ this.pos = new Vector2();
this.v = new Vector2();
this.panzer = new Piece(assets.getTexture(assets.PANZER));
}
@@ -45,6 +47,7 @@ public class BoardScreen extends AbstractScreen
public void reset()
{
+ pos.set(0, 0);
board.centerOf(0, 0, v);
panzer.centerOn(v.x, v.y);
panzer.setRotation(Orientation.DEFAULT.r());
@@ -54,6 +57,11 @@ public class BoardScreen extends AbstractScreen
{
board.toBoard(x, y, v);
GdxBoardTest.debug("BoardScreen", String.format("touchDown [%d;%d] => [%d;%d]", (int)x, (int)y, (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);
+ 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());