From 305e4d663036ea501cd227e088ebbdd146b476b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 14 Sep 2018 16:12:12 +0200 Subject: add tests for TriangleBoard --- assets/data/triangle.png | Bin 0 -> 836880 bytes test/src/ch/asynk/gdx/board/test/Assets.java | 3 +++ test/src/ch/asynk/gdx/board/test/GameBoard.java | 30 ++++++++++++++++++++++- test/src/ch/asynk/gdx/board/test/GameHud.java | 6 ++--- test/src/ch/asynk/gdx/board/test/GameScreen.java | 6 ++++- 5 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 assets/data/triangle.png diff --git a/assets/data/triangle.png b/assets/data/triangle.png new file mode 100644 index 0000000..738854b Binary files /dev/null and b/assets/data/triangle.png differ diff --git a/test/src/ch/asynk/gdx/board/test/Assets.java b/test/src/ch/asynk/gdx/board/test/Assets.java index db9d0b0..9d5c9ee 100644 --- a/test/src/ch/asynk/gdx/board/test/Assets.java +++ b/test/src/ch/asynk/gdx/board/test/Assets.java @@ -17,6 +17,7 @@ public class Assets extends ch.asynk.gdx.board.Assets public static final String CORNER = "corner.png"; public static final String MAP_00 = "map_00.png"; public static final String CHESS = "chess.jpg"; + public static final String TRI = "triangle.png"; public static final String FONT = "veteran-typewriter.ttf"; public static final String FONT_20 = "size20.ttf"; public static final String FONT_25 = "size25.ttf"; @@ -60,6 +61,7 @@ public class Assets extends ch.asynk.gdx.board.Assets { load(MAP_00, Texture.class); load(CHESS, Texture.class); + load(TRI, Texture.class); load(CORNER, Texture.class); load(PATCH, Texture.class); load(FONT_20, BitmapFont.class, params20); @@ -70,6 +72,7 @@ public class Assets extends ch.asynk.gdx.board.Assets { unload(MAP_00); unload(CHESS); + unload(TRI); unload(CORNER); unload(PATCH); unload(FONT_20); diff --git a/test/src/ch/asynk/gdx/board/test/GameBoard.java b/test/src/ch/asynk/gdx/board/test/GameBoard.java index 3d3d246..9563119 100644 --- a/test/src/ch/asynk/gdx/board/test/GameBoard.java +++ b/test/src/ch/asynk/gdx/board/test/GameBoard.java @@ -57,6 +57,12 @@ public class GameBoard implements Disposable, Touchable case SQUARE: setSQUARE(); break; + case TRI_H: + setTRI_H(); + break; + case TRI_V: + setTRI_V(); + break; } } @@ -88,9 +94,31 @@ public class GameBoard implements Disposable, Touchable r = 0; dx = 0; dy = 0; + w = map.getWidth(); + h = map.getHeight(); + this.board = BoardFactory.getBoard(BoardFactory.BoardType.SQUARE, 83, 5, 5); + } + + private void setTRI_H() + { + this.map = assets.getTexture(assets.TRI); + r = 0; + dx = 0; + dy = 0; + w = map.getWidth(); + h = map.getHeight(); + this.board = BoardFactory.getBoard(BoardFactory.BoardType.TRIANGLE, 150, 109, 53, BoardFactory.BoardOrientation.HORIZONTAL); + } + + private void setTRI_V() + { + this.map = assets.getTexture(assets.TRI); + r = 90; + dx = - ( this.map.getWidth() - this.map.getHeight() ) / 2; + dy = - dx; w = map.getHeight(); h = map.getWidth(); - this.board = BoardFactory.getBoard(BoardFactory.BoardType.SQUARE, 83, 5, 5); + this.board = BoardFactory.getBoard(BoardFactory.BoardType.TRIANGLE, 150, 16, 110, BoardFactory.BoardOrientation.VERTICAL); } public int getWidth() diff --git a/test/src/ch/asynk/gdx/board/test/GameHud.java b/test/src/ch/asynk/gdx/board/test/GameHud.java index 3fc4454..8709846 100644 --- a/test/src/ch/asynk/gdx/board/test/GameHud.java +++ b/test/src/ch/asynk/gdx/board/test/GameHud.java @@ -75,7 +75,7 @@ public class GameHud implements Disposable, Touchable updateNext(0, Alignment.BOTTOM_RIGHT); this.root.remove(this.hello); break; - case HEX_H: + default: break; } } @@ -94,9 +94,7 @@ public class GameHud implements Disposable, Touchable drawButtons(batch); drawCorners(batch); break; - case HEX_V: - case HEX_H: - case SQUARE: + default: drawRoot(batch); break; } diff --git a/test/src/ch/asynk/gdx/board/test/GameScreen.java b/test/src/ch/asynk/gdx/board/test/GameScreen.java index 63f9394..984ef5e 100644 --- a/test/src/ch/asynk/gdx/board/test/GameScreen.java +++ b/test/src/ch/asynk/gdx/board/test/GameScreen.java @@ -40,7 +40,7 @@ public class GameScreen implements Screen public enum State { - UI, HEX_V, HEX_H, SQUARE; + UI, HEX_V, HEX_H, SQUARE, TRI_H, TRI_V; public State next() { switch(this) { @@ -51,6 +51,10 @@ public class GameScreen implements Screen case HEX_H: return SQUARE; case SQUARE: + return TRI_H; + case TRI_H: + return TRI_V; + case TRI_V: return UI; default: return UI; -- cgit v1.1-2-g2b99