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.java10
-rw-r--r--core/src/ch/asynk/tankontank/game/Hex.java15
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java4
-rw-r--r--core/src/ch/asynk/tankontank/game/MapA.java4
4 files changed, 13 insertions, 20 deletions
diff --git a/core/src/ch/asynk/tankontank/game/GameFactory.java b/core/src/ch/asynk/tankontank/game/GameFactory.java
index 5ccb419..6558fc4 100644
--- a/core/src/ch/asynk/tankontank/game/GameFactory.java
+++ b/core/src/ch/asynk/tankontank/game/GameFactory.java
@@ -8,7 +8,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
import ch.asynk.tankontank.engine.Board;
-public class GameFactory implements Disposable
+public class GameFactory implements Board.TileBuilder, Disposable
{
private TextureAtlas usAtlas;
private TextureAtlas geAtlas;
@@ -136,8 +136,7 @@ public class GameFactory implements Disposable
Map m = null;
switch(t) {
case MAP_A:
- m = new MapA(config(), manager.get("images/map_a.png", Texture.class), hexAtlas);
- // m = new Map(config(), manager.get("images/map_a.png", Texture.class), hexAtlas);
+ m = new MapA(this, config(), manager.get("images/map_a.png", Texture.class));
break;
case MAP_B:
// m = new Map(config(), manager.get("images/map_b.png", Texture.class), hexAtlas);
@@ -146,4 +145,9 @@ public class GameFactory implements Disposable
return m;
}
+
+ public Hex getNewTile(float cx, float cy)
+ {
+ return new Hex(cx, cy, hexAtlas);
+ }
}
diff --git a/core/src/ch/asynk/tankontank/game/Hex.java b/core/src/ch/asynk/tankontank/game/Hex.java
index c8c7361..2d36960 100644
--- a/core/src/ch/asynk/tankontank/game/Hex.java
+++ b/core/src/ch/asynk/tankontank/game/Hex.java
@@ -25,25 +25,14 @@ public class Hex extends Tile
public static final int GREEN = 2;
public static final int BLUE = 0;
- public static TextureAtlas atlas = null;
-
public Terrain terrain;
public int roads;
- @Override
- public Hex getNewAt(float x, float y)
- {
- Hex hex = new Hex(atlas);
- hex.setPosition(x, y, 0);
- return hex;
- }
-
- public Hex(TextureAtlas atlas)
+ public Hex(float x, float y, TextureAtlas atlas)
{
- super(atlas);
+ super(x, y, atlas);
this.terrain = Terrain.CLEAR;
this.roads = 0;
- Hex.atlas = atlas;
}
@Override
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index a374e7e..afa6778 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -18,9 +18,9 @@ public abstract class Map extends Board
protected abstract void setup();
- public Map(Board.Config cfg, Texture texture, TextureAtlas hexAtlas)
+ public Map(GameFactory gameFactory, Board.Config cfg, Texture texture)
{
- super(cfg, texture, new Hex(hexAtlas));
+ super(gameFactory, cfg, texture);
setup();
}
diff --git a/core/src/ch/asynk/tankontank/game/MapA.java b/core/src/ch/asynk/tankontank/game/MapA.java
index 54a1dfb..dbfd58a 100644
--- a/core/src/ch/asynk/tankontank/game/MapA.java
+++ b/core/src/ch/asynk/tankontank/game/MapA.java
@@ -7,9 +7,9 @@ import ch.asynk.tankontank.engine.Board;
public class MapA extends Map
{
- public MapA(Board.Config cfg, Texture texture, TextureAtlas hexAtlas)
+ public MapA(GameFactory gameFactory, Board.Config cfg, Texture texture)
{
- super(cfg, texture, hexAtlas);
+ super(gameFactory, cfg, texture);
}
@Override