summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/game
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-09-17 00:04:21 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-09-17 00:04:21 +0200
commit7251086910912202b31a2a2c0318e7869bc1654d (patch)
treeb68836f7a2dcf04b0f3fd4cf966c784131751503 /core/src/ch/asynk/tankontank/game
parent92c1c362c58f9c86bb0cd203c21422a55766cd0a (diff)
downloadRustAndDust-7251086910912202b31a2a2c0318e7869bc1654d.zip
RustAndDust-7251086910912202b31a2a2c0318e7869bc1654d.tar.gz
merge HexMapFactory and UnitFactory => GameFactory
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r--core/src/ch/asynk/tankontank/game/GameFactory.java (renamed from core/src/ch/asynk/tankontank/game/UnitFactory.java)82
-rw-r--r--core/src/ch/asynk/tankontank/game/HexMapFactory.java56
2 files changed, 66 insertions, 72 deletions
diff --git a/core/src/ch/asynk/tankontank/game/UnitFactory.java b/core/src/ch/asynk/tankontank/game/GameFactory.java
index c2156ce..9dfdd6d 100644
--- a/core/src/ch/asynk/tankontank/game/UnitFactory.java
+++ b/core/src/ch/asynk/tankontank/game/GameFactory.java
@@ -1,11 +1,27 @@
package ch.asynk.tankontank.game;
import com.badlogic.gdx.assets.AssetManager;
+import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
-public class UnitFactory
+public class GameFactory
{
+ private static TextureAtlas usAtlas;
+ private static TextureAtlas geAtlas;
+
+ public static void init(AssetManager manager)
+ {
+ usAtlas = manager.get("images/us.pack", TextureAtlas.class);
+ geAtlas = manager.get("images/ge.pack", TextureAtlas.class);
+ }
+
+ public static void dispose()
+ {
+ usAtlas.dispose();
+ geAtlas.dispose();
+ }
+
public enum UnitType
{
GE_AT_GUN,
@@ -26,21 +42,6 @@ public class UnitFactory
US_WOLVERINE
}
- private static TextureAtlas usAtlas;
- private static TextureAtlas geAtlas;
-
- public static void init(AssetManager manager)
- {
- usAtlas = manager.get("images/us.pack", TextureAtlas.class);
- geAtlas = manager.get("images/ge.pack", TextureAtlas.class);
- }
-
- public static void dispose()
- {
- usAtlas.dispose();
- geAtlas.dispose();
- }
-
public static Unit getUnit(UnitType t)
{
Unit u = null;
@@ -94,4 +95,53 @@ public class UnitFactory
return u;
}
+
+ public enum MapType
+ {
+ MAP_A,
+ MAP_B
+ }
+
+ private static Map.Config config()
+ {
+ Map.Config cfg = new Map.Config();
+ cfg.cols = 11;
+ cfg.rows = 9;
+ cfg.x0 = 83;
+ cfg.y0 = 182;
+ cfg.h = 110;
+ cfg.dh = 53.6f;
+ cfg.w = 189;
+ cfg.dw = 94;
+ cfg.H = cfg.h + cfg.dh;
+ cfg.slope = (cfg.dh / (float) cfg.dw);
+
+ return cfg;
+ }
+
+ public static Map getMap(AssetManager manager, MapType t)
+ {
+ Map.Config cfg = config();
+
+ Hex[][] board = new Hex[cfg.rows][];
+ for (int i = 0; i < cfg.rows; i++) {
+ int c = cfg.cols;
+ if ((i % 2) == 1) c -= 1;
+ board[i] = new Hex[c];
+ for ( int j = 0; j < c; j ++)
+ board[i][j] = new MapHex(MapHex.Terrain.CLEAR);
+ }
+
+ Map m = null;
+ switch(t) {
+ case MAP_A:
+ m = new MapImage(config(), board, manager.get("images/map_a.png", Texture.class));
+ break;
+ case MAP_B:
+ m = new MapImage(config(), board, manager.get("images/map_b.png", Texture.class));
+ break;
+ }
+
+ return m;
+ }
}
diff --git a/core/src/ch/asynk/tankontank/game/HexMapFactory.java b/core/src/ch/asynk/tankontank/game/HexMapFactory.java
deleted file mode 100644
index ee2aa25..0000000
--- a/core/src/ch/asynk/tankontank/game/HexMapFactory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package ch.asynk.tankontank.game;
-
-import com.badlogic.gdx.assets.AssetManager;
-import com.badlogic.gdx.graphics.Texture;
-
-public class HexMapFactory
-{
- public enum MapType
- {
- MAP_A,
- MAP_B
- }
-
- private static HexMap.Config config()
- {
- HexMap.Config cfg = new HexMap.Config();
- cfg.cols = 11;
- cfg.rows = 9;
- cfg.x0 = 83;
- cfg.y0 = 182;
- cfg.h = 110;
- cfg.dh = 53.6f;
- cfg.w = 189;
- cfg.dw = 94;
- cfg.H = cfg.h + cfg.dh;
- cfg.slope = (cfg.dh / (float) cfg.dw);
-
- return cfg;
- }
-
- public static HexMap getMap(AssetManager manager, MapType t)
- {
- HexMap.Config cfg = config();
-
- Hex[][] board = new Hex[cfg.rows][];
- for (int i = 0; i < cfg.rows; i++) {
- int c = cfg.cols;
- if ((i % 2) == 1) c -= 1;
- board[i] = new Hex[c];
- for ( int j = 0; j < c; j ++)
- board[i][j] = new MapHex(MapHex.Terrain.CLEAR);
- }
-
- HexMap m = null;
- switch(t) {
- case MAP_A:
- m = new HexMapImage(config(), board, manager.get("images/map_a.png", Texture.class));
- break;
- case MAP_B:
- m = new HexMapImage(config(), board, manager.get("images/map_b.png", Texture.class));
- break;
- }
-
- return m;
- }
-}