diff --git a/android/assets/colorwheel.png b/android/assets/colorwheel.png
new file mode 100644
index 0000000..961704d
Binary files /dev/null and b/android/assets/colorwheel.png differ
diff --git a/android/assets/map_pieces/p1.tmx b/android/assets/map_pieces/p1.tmx
new file mode 100644
index 0000000..281f5e8
--- /dev/null
+++ b/android/assets/map_pieces/p1.tmx
@@ -0,0 +1,344 @@
+
+
diff --git a/android/assets/map_pieces/p2.tmx b/android/assets/map_pieces/p2.tmx
new file mode 100644
index 0000000..e07b927
--- /dev/null
+++ b/android/assets/map_pieces/p2.tmx
@@ -0,0 +1,648 @@
+
+
diff --git a/android/assets/map_pieces/p3.tmx b/android/assets/map_pieces/p3.tmx
new file mode 100644
index 0000000..2c35a90
--- /dev/null
+++ b/android/assets/map_pieces/p3.tmx
@@ -0,0 +1,648 @@
+
+
diff --git a/android/assets/map_pieces/p4.tmx b/android/assets/map_pieces/p4.tmx
new file mode 100644
index 0000000..8174632
--- /dev/null
+++ b/android/assets/map_pieces/p4.tmx
@@ -0,0 +1,344 @@
+
+
diff --git a/core/src/de/samdev/colorrunner/game/renderer/AbstractGameRenderer.java b/core/src/de/samdev/colorrunner/game/renderer/AbstractGameRenderer.java
index 542c830..b803a1e 100644
--- a/core/src/de/samdev/colorrunner/game/renderer/AbstractGameRenderer.java
+++ b/core/src/de/samdev/colorrunner/game/renderer/AbstractGameRenderer.java
@@ -9,15 +9,15 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Vector3;
public abstract class AbstractGameRenderer {
- private final static float GAME_HEIGHT = 512;
- private final static float MIN_GAME_WIDTH = 672; // ~ 512 * (4/3)
- private final static float MAX_GAME_WIDTH = 1024; // ~ 512 * (2/1) // ~~ 16:9
+ public final static float GAME_HEIGHT = 512;
+ public final static float MIN_GAME_WIDTH = 672; // ~ 512 * (4/3)
+ public final static float MAX_GAME_WIDTH = 1024; // ~ 512 * (2/1) // ~~ 16:9
private final static float FREE_ROAM_WIDTH = 1f/4f;
private int debugTextCount;
- private OrthographicCamera cam;
+ protected OrthographicCamera cam;
protected ShapeRenderer shapeRenderer;
protected BitmapFont font = new BitmapFont();
diff --git a/core/src/de/samdev/colorrunner/game/renderer/CRAssets.java b/core/src/de/samdev/colorrunner/game/renderer/CRAssets.java
index 4fe36a5..499d3c5 100644
--- a/core/src/de/samdev/colorrunner/game/renderer/CRAssets.java
+++ b/core/src/de/samdev/colorrunner/game/renderer/CRAssets.java
@@ -1,5 +1,6 @@
package de.samdev.colorrunner.game.renderer;
+import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.Texture;
@@ -15,6 +16,8 @@ public class CRAssets {
public static Texture TEX_FLOORTILE_LEFT;
public static Texture TEX_FLOORTILE_RIGHT;
+ public static Texture TEX_COLORWHEEL;
+
static {
{
Pixmap pixmap = new Pixmap(64, 64, Format.RGBA8888);
@@ -71,5 +74,7 @@ public class CRAssets {
pixmap.fill();
TEX_FLOORTILE_LEFT = new Texture(pixmap);
}
+
+ TEX_COLORWHEEL = new Texture(Gdx.files.internal("colorwheel.png"));
}
}
diff --git a/core/src/de/samdev/colorrunner/game/renderer/CRGameRenderer.java b/core/src/de/samdev/colorrunner/game/renderer/CRGameRenderer.java
index 26bb50b..7e50a09 100644
--- a/core/src/de/samdev/colorrunner/game/renderer/CRGameRenderer.java
+++ b/core/src/de/samdev/colorrunner/game/renderer/CRGameRenderer.java
@@ -1,7 +1,9 @@
package de.samdev.colorrunner.game.renderer;
+import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.math.Vector2;
+import com.badlogic.gdx.math.Vector3;
import de.samdev.colorrunner.game.world.CRGameWorld;
import de.samdev.colorrunner.game.world.entities.CRGameEntity;
@@ -28,7 +30,11 @@ public class CRGameRenderer extends AbstractGameRenderer {
endDebug();
spriteBatch.begin();
- spriteBatch.disableBlending(); // Performance, bitches
+
+ spriteBatch.enableBlending();
+ Vector3 cw_coords = cam.unproject(new Vector3(Gdx.graphics.getWidth(), 0, 0));
+ spriteBatch.draw(CRAssets.TEX_COLORWHEEL, cw_coords.x - 70, cw_coords.y - 70, 64, 64);
+ spriteBatch.disableBlending();
for (CRGameEntity e : gameworld.entities) {
spriteBatch.draw(e.getTexture(), e.bounds.x, e.bounds.y, e.bounds.width, e.bounds.height);
diff --git a/core/src/de/samdev/colorrunner/game/world/CRGameWorld.java b/core/src/de/samdev/colorrunner/game/world/CRGameWorld.java
index 834d385..7d02581 100644
--- a/core/src/de/samdev/colorrunner/game/world/CRGameWorld.java
+++ b/core/src/de/samdev/colorrunner/game/world/CRGameWorld.java
@@ -3,78 +3,34 @@ package de.samdev.colorrunner.game.world;
import java.util.ArrayList;
import java.util.List;
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.math.Vector2;
+
+import de.samdev.colorrunner.game.renderer.AbstractGameRenderer;
import de.samdev.colorrunner.game.world.entities.CRGameEntity;
import de.samdev.colorrunner.game.world.entities.gameentities.PlayerEntity;
import de.samdev.colorrunner.game.world.entities.gameentities.floor.DownStateFloorTileEntity;
+import de.samdev.colorrunner.game.world.entities.gameentities.floor.FloorTileEntity;
import de.samdev.colorrunner.game.world.entities.gameentities.floor.LeftStateFloorTileEntity;
import de.samdev.colorrunner.game.world.entities.gameentities.floor.RightStateFloorTileEntity;
import de.samdev.colorrunner.game.world.entities.gameentities.floor.UpStateFloorTileEntity;
+import de.samdev.colorrunner.game.world.map.CRMapStorage;
+import de.samdev.colorrunner.game.world.map.CRTiledMap;
import de.samdev.colorrunner.input.GameInputListener;
public class CRGameWorld implements GameInputListener {
-
public PlayerEntity player;
public List entities = new ArrayList();
public FPSCounter fps = new FPSCounter();
+ private float mapRightBoundary = 0;
+
public CRGameWorld() {
-
addEntity(player = new PlayerEntity(this, 40, 290));
- addEntity(new UpStateFloorTileEntity(this, 1 * 32, 32));
- addEntity(new UpStateFloorTileEntity(this, 2 * 32, 32));
- addEntity(new UpStateFloorTileEntity(this, 3 * 32, 32));
- addEntity(new UpStateFloorTileEntity(this, 4 * 32, 32));
- addEntity(new UpStateFloorTileEntity(this, 5 * 32, 32));
- addEntity(new UpStateFloorTileEntity(this, 6 * 32, 32));
- addEntity(new UpStateFloorTileEntity(this, 7 * 32, 32));
- addEntity(new UpStateFloorTileEntity(this, 8 * 32, 32));
- addEntity(new UpStateFloorTileEntity(this, 9 * 32, 32));
- addEntity(new UpStateFloorTileEntity(this, 10 * 32, 32));
- addEntity(new UpStateFloorTileEntity(this, 11 * 32, 32));
- addEntity(new UpStateFloorTileEntity(this, 12 * 32, 32));
- addEntity(new UpStateFloorTileEntity(this, 13 * 32, 32));
- addEntity(new UpStateFloorTileEntity(this, 14 * 32, 32));
- addEntity(new UpStateFloorTileEntity(this, 15 * 32, 32));
- addEntity(new UpStateFloorTileEntity(this, 16 * 32, 32));
- addEntity(new UpStateFloorTileEntity(this, 17 * 32, 32));
-
- addEntity(new UpStateFloorTileEntity(this, 18 * 32, 1 * 32));
- addEntity(new UpStateFloorTileEntity(this, 19 * 32, 2 * 32));
- addEntity(new UpStateFloorTileEntity(this, 19 * 32, 3 * 32));
- addEntity(new UpStateFloorTileEntity(this, 18 * 32, 4 * 32));
- addEntity(new UpStateFloorTileEntity(this, 18 * 32, 5 * 32));
- addEntity(new UpStateFloorTileEntity(this, 19 * 32, 6 * 32));
- addEntity(new UpStateFloorTileEntity(this, 20 * 32, 7 * 32));
-
- addEntity(new RightStateFloorTileEntity(this, 21 * 32, 32));
- addEntity(new RightStateFloorTileEntity(this, 22 * 32, 32));
- addEntity(new RightStateFloorTileEntity(this, 26 * 32, 32));
- addEntity(new RightStateFloorTileEntity(this, 27 * 32, 32));
- addEntity(new RightStateFloorTileEntity(this, 28 * 32, 32));
- addEntity(new RightStateFloorTileEntity(this, 29 * 32, 32));
- addEntity(new RightStateFloorTileEntity(this, 29 * 32, 64));
-
- addEntity(new LeftStateFloorTileEntity(this, 32 * 32, 32));
- addEntity(new LeftStateFloorTileEntity(this, 33 * 32, 32));
- addEntity(new LeftStateFloorTileEntity(this, 34 * 32, 32));
- addEntity(new LeftStateFloorTileEntity(this, 35 * 32, 32));
- addEntity(new LeftStateFloorTileEntity(this, 36 * 32, 32));
- addEntity(new LeftStateFloorTileEntity(this, 37 * 32, 32));
- addEntity(new LeftStateFloorTileEntity(this, 38 * 32, 32));
- addEntity(new LeftStateFloorTileEntity(this, 39 * 32, 32));
-
- addEntity(new DownStateFloorTileEntity(this, 11 * 32, 456));
- addEntity(new DownStateFloorTileEntity(this, 12 * 32, 456));
- addEntity(new DownStateFloorTileEntity(this, 13 * 32, 456));
- addEntity(new DownStateFloorTileEntity(this, 14 * 32, 456));
- addEntity(new DownStateFloorTileEntity(this, 15 * 32, 456));
- addEntity(new DownStateFloorTileEntity(this, 16 * 32, 456));
- addEntity(new DownStateFloorTileEntity(this, 17 * 32, 456));
- addEntity(new DownStateFloorTileEntity(this, 18 * 32, 456));
- addEntity(new DownStateFloorTileEntity(this, 19 * 32, 456));
+ expandMap();
}
public void update(float delta) {
@@ -83,6 +39,15 @@ public class CRGameWorld implements GameInputListener {
for (CRGameEntity ent : entities) {
ent.update(delta);
}
+
+ expandMap();
+ }
+
+ private void expandMap() {
+ while (player.bounds.x + AbstractGameRenderer.MAX_GAME_WIDTH*2 > mapRightBoundary) {
+ float width = appendMap(CRMapStorage.getMap(), new Vector2(mapRightBoundary, 0));
+ mapRightBoundary += width;
+ }
}
public CRGameEntity addEntity(CRGameEntity ent) {
@@ -91,6 +56,42 @@ public class CRGameWorld implements GameInputListener {
return ent;
}
+ private float appendMap(CRTiledMap map, Vector2 pos) {
+ int height = map.getHeight();
+ int width = map.getWidth();
+
+ for (int x = 0; x < width; x++) {
+ for (int y = 0; y < height; y++) {
+ float px = pos.x + x * FloorTileEntity.FLOORTILE_WIDTH;
+ float py = pos.y + (height - y) * FloorTileEntity.FLOORTILE_WIDTH;
+
+ switch (map.getGID(x, y)) {
+
+ case CRTiledMap.GID_EMPTY: break;
+
+ case CRTiledMap.GID_UP:
+ addEntity(new UpStateFloorTileEntity(this, px, py));
+ break;
+ case CRTiledMap.GID_RIGHT:
+ addEntity(new RightStateFloorTileEntity(this, px, py));
+ break;
+ case CRTiledMap.GID_DOWN:
+ addEntity(new DownStateFloorTileEntity(this, px, py));
+ break;
+ case CRTiledMap.GID_LEFT:
+ addEntity(new LeftStateFloorTileEntity(this, px, py));
+ break;
+
+ default:
+ Gdx.app.error("MapLoad", "Unknown GID: " + map.getGID(x, y));
+ break;
+ }
+ }
+ }
+
+ return width * FloorTileEntity.FLOORTILE_WIDTH;
+ }
+
@Override
public void doJump() {
player.jump();
diff --git a/core/src/de/samdev/colorrunner/game/world/map/CRMapStorage.java b/core/src/de/samdev/colorrunner/game/world/map/CRMapStorage.java
new file mode 100644
index 0000000..1bc10ab
--- /dev/null
+++ b/core/src/de/samdev/colorrunner/game/world/map/CRMapStorage.java
@@ -0,0 +1,27 @@
+package de.samdev.colorrunner.game.world.map;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import com.badlogic.gdx.Gdx;
+
+public class CRMapStorage {
+ public static final Random random = new Random();
+ public static final List maps = new ArrayList();
+
+ public static final CRTiledMap map_01 = register("p1.tmx");
+ public static final CRTiledMap map_02 = register("p2.tmx");
+ public static final CRTiledMap map_03 = register("p3.tmx");
+ public static final CRTiledMap map_04 = register("p4.tmx");
+
+ public static CRTiledMap register(String path) {
+ CRTiledMap m = CRTiledMap.load(Gdx.files.internal("map_pieces/" + path).readString());
+ maps.add(m);
+ return m;
+ }
+
+ public static CRTiledMap getMap() {
+ return maps.get(random.nextInt(maps.size()));
+ }
+}
diff --git a/core/src/de/samdev/colorrunner/game/world/map/CRTiledMap.java b/core/src/de/samdev/colorrunner/game/world/map/CRTiledMap.java
new file mode 100644
index 0000000..c9d0887
--- /dev/null
+++ b/core/src/de/samdev/colorrunner/game/world/map/CRTiledMap.java
@@ -0,0 +1,56 @@
+package de.samdev.colorrunner.game.world.map;
+
+import com.badlogic.gdx.utils.Array;
+import com.badlogic.gdx.utils.XmlReader;
+import com.badlogic.gdx.utils.XmlReader.Element;
+
+public class CRTiledMap {
+ public final static int GID_EMPTY = 0;
+
+ public final static int GID_MID = 13;
+ public final static int GID_UP = 8;
+ public final static int GID_RIGHT = 14;
+ public final static int GID_DOWN = 18;
+ public final static int GID_LEFT = 12;
+
+ public int width;
+ public int height;
+
+ public int[][] map;
+
+ public static CRTiledMap load(String inputXmlString) {
+ CRTiledMap result = new CRTiledMap();
+
+ XmlReader reader = new XmlReader();
+ Element root = reader.parse(inputXmlString);
+
+ Element elemLayer = root.getChildByName("layer");
+ Element elemData = elemLayer.getChildByName("data");
+ Array tiles = elemData.getChildrenByName("tile");
+
+ int width = elemLayer.getInt("width");
+ int height = elemLayer.getInt("height");
+
+ result.map = new int[width][height];
+ result.width = width;
+ result.height = height;
+
+ for (int i = 0; i < tiles.size; i++) {
+ result.map[i % width][i / width] = tiles.get(i).getInt("gid");
+ }
+
+ return result;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ public int getGID(int x, int y) {
+ return map[x][y];
+ }
+}
diff --git a/data/Tileset.pdn b/data/Tileset.pdn
new file mode 100644
index 0000000..eb0c7f2
Binary files /dev/null and b/data/Tileset.pdn differ
diff --git a/data/Tileset.png b/data/Tileset.png
new file mode 100644
index 0000000..bdfe108
Binary files /dev/null and b/data/Tileset.png differ
diff --git a/data/Tileset.tsx b/data/Tileset.tsx
new file mode 100644
index 0000000..1c4f42e
--- /dev/null
+++ b/data/Tileset.tsx
@@ -0,0 +1,4 @@
+
+
+
+