diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-21 04:25:05 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-21 04:25:05 +0200 |
commit | fca82703546c3d88c8683ed472ef8ea56e9e1d6d (patch) | |
tree | f57376219cc7abdec55eb16491b7aba556c04ba0 /core/src/ch/asynk/tankontank/game | |
parent | c3782d4c097f4e053239e0c0aeff5335f99cc4ee (diff) | |
download | RustAndDust-fca82703546c3d88c8683ed472ef8ea56e9e1d6d.zip RustAndDust-fca82703546c3d88c8683ed472ef8ea56e9e1d6d.tar.gz |
fix Hex and GameFactory to follow TileOverlays
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/GameFactory.java | 18 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hex.java | 34 |
2 files changed, 21 insertions, 31 deletions
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(); - } } |