summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2018-09-13 16:40:42 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2018-09-13 16:40:42 +0200
commit88188156cfaf037866b5242fc1b06dd9754c2b94 (patch)
treec2cca384cd54dcda21346e3dfb4883266b5426e5 /core/src/ch/asynk
parent8dd8abf9372b35e2cc01cbad3e683d13979a1631 (diff)
downloadgdx-boardgame-88188156cfaf037866b5242fc1b06dd9754c2b94.zip
gdx-boardgame-88188156cfaf037866b5242fc1b06dd9754c2b94.tar.gz
add SquareBoard test
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/zproject/Assets.java3
-rw-r--r--core/src/ch/asynk/zproject/GameBoard.java31
-rw-r--r--core/src/ch/asynk/zproject/GameScreen.java4
3 files changed, 30 insertions, 8 deletions
diff --git a/core/src/ch/asynk/zproject/Assets.java b/core/src/ch/asynk/zproject/Assets.java
index 095a052..a5048e6 100644
--- a/core/src/ch/asynk/zproject/Assets.java
+++ b/core/src/ch/asynk/zproject/Assets.java
@@ -16,6 +16,7 @@ public class Assets extends ch.asynk.zproject.engine.Assets
public static final String CORNER = "data/corner.png";
public static final String MAP_00 = "data/map_00.png";
+ public static final String CHESS = "data/chess.jpg";
public static final String FONT = "data/veteran-typewriter.ttf";
public static final String FONT_20 = "size20.ttf";
public static final String FONT_25 = "size25.ttf";
@@ -58,6 +59,7 @@ public class Assets extends ch.asynk.zproject.engine.Assets
public void loadGame()
{
load(MAP_00, Texture.class);
+ load(CHESS, Texture.class);
load(CORNER, Texture.class);
load(PATCH, Texture.class);
load(FONT_20, BitmapFont.class, params20);
@@ -67,6 +69,7 @@ public class Assets extends ch.asynk.zproject.engine.Assets
public void unloadGame()
{
unload(MAP_00);
+ unload(CHESS);
unload(CORNER);
unload(PATCH);
unload(FONT_20);
diff --git a/core/src/ch/asynk/zproject/GameBoard.java b/core/src/ch/asynk/zproject/GameBoard.java
index 4d3f774..b855ff2 100644
--- a/core/src/ch/asynk/zproject/GameBoard.java
+++ b/core/src/ch/asynk/zproject/GameBoard.java
@@ -11,7 +11,8 @@ import ch.asynk.zproject.engine.board.BoardFactory;
public class GameBoard implements Disposable, Touchable
{
- private final Texture map;
+ private final Assets assets;
+ private Texture map;
private Board board;
private int dx;
@@ -24,7 +25,7 @@ public class GameBoard implements Disposable, Touchable
public GameBoard(final Assets assets)
{
- this.map = assets.getTexture(assets.MAP_00);
+ this.assets = assets;
this.v = new Vector2();
setState(GameScreen.State.UI);
}
@@ -53,27 +54,43 @@ public class GameBoard implements Disposable, Touchable
case HEX_H:
setHEX_H();
break;
+ case SQUARE:
+ setSQUARE();
+ break;
}
}
private void setHEX_V()
{
+ this.map = assets.getTexture(assets.MAP_00);
r = 0;
dx = 0;
dy = 0;
- w = map.getWidth();
- h = map.getHeight();
- this.board = BoardFactory.getBoard(BoardFactory.BoardType.HEX, 10, 9, 110, 50, 103, BoardFactory.BoardOrientation.VERTICAL);
+ w = this.map.getWidth();
+ h = this.map.getHeight();
+ this.board = BoardFactory.getBoard(BoardFactory.BoardType.HEX, 110, 50, 103, BoardFactory.BoardOrientation.VERTICAL);
}
private void setHEX_H()
{
+ this.map = assets.getTexture(assets.MAP_00);
r = 90;
- dx = - ( map.getWidth() - map.getHeight() ) / 2;
+ dx = - ( this.map.getWidth() - this.map.getHeight() ) / 2;
dy = - dx;
+ w = this.map.getWidth();
+ h = this.map.getHeight();
+ this.board = BoardFactory.getBoard(BoardFactory.BoardType.HEX, 110, 103, 50, BoardFactory.BoardOrientation.HORIZONTAL);
+ }
+
+ private void setSQUARE()
+ {
+ this.map = assets.getTexture(assets.CHESS);
+ r = 0;
+ dx = 0;
+ dy = 0;
w = map.getHeight();
h = map.getWidth();
- this.board = BoardFactory.getBoard(BoardFactory.BoardType.HEX, 9, 10, 110, 103, 50, BoardFactory.BoardOrientation.HORIZONTAL);
+ this.board = BoardFactory.getBoard(BoardFactory.BoardType.SQUARE, 83, 5, 5);
}
public int getWidth()
diff --git a/core/src/ch/asynk/zproject/GameScreen.java b/core/src/ch/asynk/zproject/GameScreen.java
index 02b7db5..10eaacd 100644
--- a/core/src/ch/asynk/zproject/GameScreen.java
+++ b/core/src/ch/asynk/zproject/GameScreen.java
@@ -40,7 +40,7 @@ public class GameScreen implements Screen
public enum State
{
- UI, HEX_V, HEX_H;
+ UI, HEX_V, HEX_H, SQUARE;
public State next()
{
switch(this) {
@@ -49,6 +49,8 @@ public class GameScreen implements Screen
case HEX_V:
return HEX_H;
case HEX_H:
+ return SQUARE;
+ case SQUARE:
return UI;
default:
return UI;