summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/src/ch/asynk/tankontank/TankOnTank.java4
-rw-r--r--core/src/ch/asynk/tankontank/game/GameFactory.java18
-rw-r--r--core/src/ch/asynk/tankontank/game/Hex.java34
3 files changed, 23 insertions, 33 deletions
diff --git a/core/src/ch/asynk/tankontank/TankOnTank.java b/core/src/ch/asynk/tankontank/TankOnTank.java
index 8501e19..57bd092 100644
--- a/core/src/ch/asynk/tankontank/TankOnTank.java
+++ b/core/src/ch/asynk/tankontank/TankOnTank.java
@@ -34,9 +34,9 @@ public class TankOnTank extends Game
// manager.load("images/map_b.png", Texture.class);
manager.load("images/dice.pack", TextureAtlas.class);
manager.load("images/counters.pack", TextureAtlas.class);
- manager.load("images/hex.png", Texture.class);
manager.load("images/ge.atlas", TextureAtlas.class);
manager.load("images/us.atlas", TextureAtlas.class);
+ manager.load("images/hex.atlas", TextureAtlas.class);
// manager.load("images/cup.jpg", Texture.class);
// manager.load("images/small.png", Texture.class);
}
@@ -49,9 +49,9 @@ public class TankOnTank extends Game
// manager.unload("images/map_b.png");
manager.unload("images/dice.pack");
manager.unload("images/counters.pack");
- manager.unload("images/hex.png");
manager.unload("images/ge.atlas");
manager.unload("images/us.atlas");
+ manager.unload("images/hex.atlas");
// manager.unload("images/cup.jpg");
// manager.unload("images/small.png");
Gdx.app.debug("TankOnTank", "diagnostics:\n" + manager.getDiagnostics() );
diff --git a/core/src/ch/asynk/tankontank/game/GameFactory.java b/core/src/ch/asynk/tankontank/game/GameFactory.java
index 27fc239..f8b05ea 100644
--- a/core/src/ch/asynk/tankontank/game/GameFactory.java
+++ b/core/src/ch/asynk/tankontank/game/GameFactory.java
@@ -13,17 +13,20 @@ public class GameFactory
{
private static TextureAtlas usAtlas;
private static TextureAtlas geAtlas;
+ private static TextureAtlas hexAtlas;
public static void init(AssetManager manager)
{
usAtlas = manager.get("images/us.atlas", TextureAtlas.class);
geAtlas = manager.get("images/ge.atlas", TextureAtlas.class);
+ hexAtlas = manager.get("images/hex.atlas", TextureAtlas.class);
}
public static void dispose()
{
usAtlas.dispose();
geAtlas.dispose();
+ hexAtlas.dispose();
}
public enum UnitType
@@ -128,12 +131,19 @@ public class GameFactory
Map.Config cfg = config();
Tile[][] board = new Tile[cfg.rows][];
+ boolean evenRow = true;
for (int i = 0; i < cfg.rows; i++) {
- int c = cfg.cols;
- if ((i % 2) == 1) c -= 1;
+ float y = cfg.y0 + (i * cfg.h) - cfg.dh;
+ int c = (evenRow ? cfg.cols : cfg.cols - 1);
board[i] = new Tile[c];
- for ( int j = 0; j < c; j ++)
- board[i][j] = new Hex(Hex.Terrain.CLEAR);
+ for ( int j = 0; j < c; j ++) {
+ float x = cfg.x0 + (j * cfg.w) ;//+ (cfg.w / 2f);
+ if (!evenRow) x += cfg.dw;
+ Hex hex = new Hex(Hex.Terrain.CLEAR, hexAtlas);
+ hex.setPosition(x, y, 0);
+ board[i][j] = hex;
+ }
+ evenRow = !evenRow;
}
Map m = null;
diff --git a/core/src/ch/asynk/tankontank/game/Hex.java b/core/src/ch/asynk/tankontank/game/Hex.java
index 1222363..2d07b52 100644
--- a/core/src/ch/asynk/tankontank/game/Hex.java
+++ b/core/src/ch/asynk/tankontank/game/Hex.java
@@ -1,11 +1,10 @@
package ch.asynk.tankontank.game;
-import java.util.ArrayDeque;
+import com.badlogic.gdx.graphics.g2d.TextureAtlas;
-import ch.asynk.tankontank.engine.Tile;
-import ch.asynk.tankontank.engine.Pawn;
+import ch.asynk.tankontank.engine.TileOverlays;
-public class Hex implements Tile
+public class Hex extends TileOverlays
{
public enum Terrain
{
@@ -17,20 +16,19 @@ public class Hex implements Tile
public Terrain terrain;
public int roads;
- private ArrayDeque<Pawn> stack;
- public Hex(Terrain t)
+ public Hex(Terrain t, TextureAtlas atlas)
{
+ super(atlas);
this.terrain = t;
this.roads = 0;
- this.stack = null;
}
- public Hex(Terrain t, int roads)
+ public Hex(Terrain t, int roads, TextureAtlas atlas)
{
+ super(atlas);
this.terrain = t;
this.roads = roads;
- this.stack = null;
}
public int costFrom(Side side)
@@ -51,22 +49,4 @@ public class Hex implements Tile
return c;
}
-
- public int push(Pawn pawn)
- {
- if (stack == null) stack = new ArrayDeque<Pawn>();
- stack.push(pawn);
- return stack.size();
- }
-
- public void remove(Pawn pawn)
- {
- stack.remove(pawn);
- }
-
- public Pawn getTop()
- {
- if ((stack == null) || (stack.size() == 0)) return null;
- return stack.getFirst();
- }
}