summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/game
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r--core/src/ch/asynk/tankontank/game/GameFactory.java18
-rw-r--r--core/src/ch/asynk/tankontank/game/Hex.java4
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java41
-rw-r--r--core/src/ch/asynk/tankontank/game/Unit.java4
4 files changed, 53 insertions, 14 deletions
diff --git a/core/src/ch/asynk/tankontank/game/GameFactory.java b/core/src/ch/asynk/tankontank/game/GameFactory.java
index f8b05ea..e271f4b 100644
--- a/core/src/ch/asynk/tankontank/game/GameFactory.java
+++ b/core/src/ch/asynk/tankontank/game/GameFactory.java
@@ -5,9 +5,7 @@ import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
-import ch.asynk.tankontank.engine.Map;
-import ch.asynk.tankontank.engine.MapNode;
-import ch.asynk.tankontank.engine.Tile;
+import ch.asynk.tankontank.engine.Board;
public class GameFactory
{
@@ -109,9 +107,9 @@ public class GameFactory
MAP_B
}
- private static Map.Config config()
+ private static Board.Config config()
{
- Map.Config cfg = new Map.Config();
+ Board.Config cfg = new Board.Config();
cfg.cols = 11;
cfg.rows = 9;
cfg.x0 = 83;
@@ -128,14 +126,14 @@ public class GameFactory
public static Map getMap(AssetManager manager, MapType t)
{
- Map.Config cfg = config();
+ Board.Config cfg = config();
- Tile[][] board = new Tile[cfg.rows][];
+ Hex[][] board = new Hex[cfg.rows][];
boolean evenRow = true;
for (int i = 0; i < cfg.rows; i++) {
float y = cfg.y0 + (i * cfg.h) - cfg.dh;
int c = (evenRow ? cfg.cols : cfg.cols - 1);
- board[i] = new Tile[c];
+ board[i] = new Hex[c];
for ( int j = 0; j < c; j ++) {
float x = cfg.x0 + (j * cfg.w) ;//+ (cfg.w / 2f);
if (!evenRow) x += cfg.dw;
@@ -149,10 +147,10 @@ public class GameFactory
Map m = null;
switch(t) {
case MAP_A:
- m = new MapNode(config(), board, manager.get("images/map_a.png", Texture.class));
+ m = new Map(config(), board, manager.get("images/map_a.png", Texture.class));
break;
case MAP_B:
- m = new MapNode(config(), board, manager.get("images/map_b.png", Texture.class));
+ m = new Map(config(), board, manager.get("images/map_b.png", Texture.class));
break;
}
diff --git a/core/src/ch/asynk/tankontank/game/Hex.java b/core/src/ch/asynk/tankontank/game/Hex.java
index 2d07b52..ae6499e 100644
--- a/core/src/ch/asynk/tankontank/game/Hex.java
+++ b/core/src/ch/asynk/tankontank/game/Hex.java
@@ -2,9 +2,9 @@ package ch.asynk.tankontank.game;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
-import ch.asynk.tankontank.engine.TileOverlays;
+import ch.asynk.tankontank.engine.Tile;
-public class Hex extends TileOverlays
+public class Hex extends Tile
{
public enum Terrain
{
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
new file mode 100644
index 0000000..9eef409
--- /dev/null
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -0,0 +1,41 @@
+package ch.asynk.tankontank.game;
+
+import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.math.GridPoint2;
+
+import ch.asynk.tankontank.engine.Board;
+import ch.asynk.tankontank.engine.Pawn;
+
+public class Map extends Board
+{
+ private Pawn currentPawn;
+ private GridPoint2 currentHex = new GridPoint2(-1, -1);
+
+ public Map(Board.Config cfg, Hex[][] board, Texture texture)
+ {
+ super(cfg, board, texture);
+ }
+
+ public boolean drag(float dx, float dy)
+ {
+ if (currentPawn == null) return false;
+ currentPawn.translate(dx, dy);
+ return true;
+ }
+
+ public void touchDown(float x, float y)
+ {
+ getHexAt(currentHex, x, y);
+ if (currentHex.x != -1) {
+ currentPawn = getTopPawnAt(currentHex);
+ }
+ }
+
+ public void touchUp(float x, float y)
+ {
+ getHexAt(currentHex, x, y);
+ if (currentPawn != null) {
+ movePawnTo(currentPawn, currentHex);
+ }
+ }
+}
diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java
index 61833eb..31a822d 100644
--- a/core/src/ch/asynk/tankontank/game/Unit.java
+++ b/core/src/ch/asynk/tankontank/game/Unit.java
@@ -2,9 +2,9 @@ package ch.asynk.tankontank.game;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
-import ch.asynk.tankontank.engine.PawnImage;
+import ch.asynk.tankontank.engine.Pawn;
-public class Unit extends PawnImage
+public class Unit extends Pawn
{
public int rng;
public int def;