diff --git a/android/assets/levels/plevel001.tmx b/android/assets/levels/plevel001.tmx
index 23f210e..d42f5fb 100644
--- a/android/assets/levels/plevel001.tmx
+++ b/android/assets/levels/plevel001.tmx
@@ -8521,7 +8521,7 @@
-
+
@@ -9013,6 +9013,7 @@
+
@@ -9020,8 +9021,7 @@
-
-
+
@@ -14515,6 +14515,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -14672,6 +14685,493 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
diff --git a/core/src/de/samdev/colorrunner/CRGame.java b/core/src/de/samdev/colorrunner/CRGame.java
index 310091c..81b4c3f 100644
--- a/core/src/de/samdev/colorrunner/CRGame.java
+++ b/core/src/de/samdev/colorrunner/CRGame.java
@@ -9,7 +9,7 @@ import com.badlogic.gdx.audio.Music;
import de.samdev.colorrunner.screens.menu.SplashScreen;
public class CRGame extends Game {
- public final static boolean DEBUG = false;
+ public final static boolean DEBUG = true;
public static AssetManager manager;
diff --git a/core/src/de/samdev/colorrunner/game/renderer/AbstractGameRenderer.java b/core/src/de/samdev/colorrunner/game/renderer/AbstractGameRenderer.java
index 9660309..2373ca5 100644
--- a/core/src/de/samdev/colorrunner/game/renderer/AbstractGameRenderer.java
+++ b/core/src/de/samdev/colorrunner/game/renderer/AbstractGameRenderer.java
@@ -87,29 +87,29 @@ public abstract class AbstractGameRenderer {
fontBatch.begin();
font.setColor(1, 0, 1, 1);
- debugTextCount = 2;
+ debugTextCount = 0;
}
protected void beginHud(){
fontBatch2.begin();
font2.setColor(Color.RED);
//font2.setColor(0, 1, 1, 1);
- hudTextCount = 0;
+ //hudTextCount = 0;
}
protected void renderDebug(String s) {
Vector3 coords = cam.unproject(new Vector3(10, 10, 0));
-// font.draw(fontBatch, s, coords.x, coords.y - debugTextCount++ * 20);
+ font.draw(fontBatch, s, coords.x, coords.y - debugTextCount++ * 20);
}
protected void renderHud(String s, int xCoord){
//Vector3 coords = cam.unproject(new Vector3(10, 10, 0));
- if (hudTextCount == 0)
- font2.setColor(Color.RED);
- if (hudTextCount == 1)
- font2.setColor(Color.GREEN);
+ //if (hudTextCount == 0)
+ // font2.setColor(Color.RED);
+ //if (hudTextCount == 1)
+ // font2.setColor(Color.GREEN);
- hudTextCount++;
- font2.draw(fontBatch2, s, xCoord, Gdx.graphics.getHeight() - 20);
+ //hudTextCount++;
+ //font2.draw(fontBatch2, s, xCoord, Gdx.graphics.getHeight() - 20);
}
protected void endDebug() {
diff --git a/core/src/de/samdev/colorrunner/game/renderer/CRGameRenderer.java b/core/src/de/samdev/colorrunner/game/renderer/CRGameRenderer.java
index 769a6bb..5106a82 100644
--- a/core/src/de/samdev/colorrunner/game/renderer/CRGameRenderer.java
+++ b/core/src/de/samdev/colorrunner/game/renderer/CRGameRenderer.java
@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
+import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
@@ -11,6 +12,8 @@ import de.samdev.colorrunner.CRGame;
import de.samdev.colorrunner.game.world.CRGameWorld;
import de.samdev.colorrunner.game.world.entities.CRGameEntity;
import de.samdev.colorrunner.game.world.entities.MovingEntity;
+import de.samdev.colorrunner.game.world.entities.StaticEntity;
+import de.samdev.colorrunner.game.world.entities.gameentities.floor.FloorTileEntity;
import de.samdev.colorrunner.game.world.map.provider.EndlessMapProvider;
import de.samdev.colorrunner.game.world.map.provider.StaticMapProvider;
@@ -31,7 +34,7 @@ public class CRGameRenderer extends AbstractGameRenderer {
gameworld.camViewBoundaries = getCamViewRectangle();
renderMain();
- renderHud();
+ //renderHud();
if (CRGame.DEBUG) renderDebugBoxes();
@@ -52,7 +55,52 @@ public class CRGameRenderer extends AbstractGameRenderer {
shapeRenderer.line(me.bounds.getCenter(new Vector2()), me.bounds.getCenter(new Vector2()).add(0 , me.getVelocity().y / 15f));
}
}
-
+
+ shapeRenderer.end();
+ shapeRenderer.begin(ShapeType.Line);
+
+ Rectangle bounds = gameworld.camViewBoundaries;
+
+ float ftw = FloorTileEntity.FLOORTILE_WIDTH;
+
+ int minx = (int)((bounds.getX() + 0) / ftw) - 2;
+ int miny = (int)((bounds.getY() + 0) / ftw) - 2;
+ int maxx = (int)((bounds.getX() + bounds.getWidth()) / ftw) + 2;
+ int maxy = (int)((bounds.getY() + bounds.getHeight()) / ftw) + 2;
+
+ for (int x = minx; x < maxx; x++)
+ {
+ for (int y = miny; y < maxy; y++)
+ {
+ switch (gameworld.mapprovider.getTrigger(x, y))
+ {
+ case RUNBOTTOM:
+ shapeRenderer.setColor(1, 0, 0, 1f);
+ shapeRenderer.rect(x*ftw+0, y*ftw+0, ftw-0, ftw-0);
+ shapeRenderer.rect(x*ftw+4, y*ftw+4, ftw-8, ftw-8);
+ shapeRenderer.rect(x*ftw+8, y*ftw+8, ftw-16, ftw-16);
+ shapeRenderer.rect(x*ftw+12, y*ftw+12, ftw-24, ftw-24);
+ break;
+ case RUNTOP:
+ shapeRenderer.setColor(0, 1, 0, 1f);
+ shapeRenderer.rect(x*ftw+0, y*ftw+0, ftw-0, ftw-0);
+ shapeRenderer.rect(x*ftw+4, y*ftw+4, ftw-8, ftw-8);
+ shapeRenderer.rect(x*ftw+8, y*ftw+8, ftw-16, ftw-16);
+ shapeRenderer.rect(x*ftw+12, y*ftw+12, ftw-24, ftw-24);
+ break;
+ case FLY:
+ shapeRenderer.setColor(0, 0, 1, 1f);
+ shapeRenderer.rect(x*ftw+0, y*ftw+0, ftw-0, ftw-0);
+ shapeRenderer.rect(x*ftw+4, y*ftw+4, ftw-8, ftw-8);
+ shapeRenderer.rect(x*ftw+8, y*ftw+8, ftw-16, ftw-16);
+ shapeRenderer.rect(x*ftw+12, y*ftw+12, ftw-24, ftw-24);
+ break;
+ case NOTHING:
+ break;
+ }
+ }
+ }
+
shapeRenderer.end();
}
@@ -81,15 +129,24 @@ public class CRGameRenderer extends AbstractGameRenderer {
private void renderDebugInfo() {
beginDebug();
+
renderDebug("FPS: " + (int)gameworld.fps.getFPS());
+
renderDebug("Entitys: " + gameworld.entities.size());
+
renderDebug("ExecTime: " + (int)(avgExecTime*100) / 100.0+ " / " + (int)(10000/gameworld.fps.getFPS())/10.0 + "ms (" + (int)((avgExecTime/(1000/gameworld.fps.getFPS()))*1000) / 10.0 + "%)");
+
renderDebug("CameraOffset: (" + (int)cam.position.x + "|" + (int)cam.position.y + ")");
+
renderDebug("Player(x): " + (int)gameworld.player.bounds.x);
if (gameworld.mapprovider instanceof EndlessMapProvider)
renderDebug("Procedural Piece: \"" + ((EndlessMapProvider)gameworld.mapprovider).getCurrentSection(gameworld.player.bounds).piece_name + "\"");
else if (gameworld.mapprovider instanceof StaticMapProvider)
renderDebug("Level Progress: " + ((StaticMapProvider)gameworld.mapprovider).mapPlayerPos + "/" + ((StaticMapProvider)gameworld.mapprovider).mapMaxWidth);
+
+ renderDebug("Player(tile): [" + (int)(gameworld.player.bounds.x / FloorTileEntity.FLOORTILE_WIDTH) + "|" + (int)(gameworld.player.bounds.y / FloorTileEntity.FLOORTILE_WIDTH) + "]");
+ renderDebug("Player(trigger): " + gameworld.mapprovider.getTrigger((int)(gameworld.player.bounds.x / FloorTileEntity.FLOORTILE_WIDTH), (int)(gameworld.player.bounds.y / FloorTileEntity.FLOORTILE_WIDTH)));
+
endDebug();
}
diff --git a/core/src/de/samdev/colorrunner/game/world/map/CRTiledMap.java b/core/src/de/samdev/colorrunner/game/world/map/CRTiledMap.java
index 9fcaf9e..0b5b9ae 100644
--- a/core/src/de/samdev/colorrunner/game/world/map/CRTiledMap.java
+++ b/core/src/de/samdev/colorrunner/game/world/map/CRTiledMap.java
@@ -22,9 +22,9 @@ public class CRTiledMap {
public final static int GID_RIGHT = 24;
public final static int GID_DOWN = 33;
public final static int GID_LEFT = 22;
- public final static int GID_INTER_UP = 18;
- public final static int GID_INTER_DOWN = 19;
- public final static int GID_INTER_RIGHT = 20;
+ public final static int GID_INTER_UP = 16;
+ public final static int GID_INTER_DOWN = 17;
+ public final static int GID_INTER_RIGHT = 18;
public int width;
public int height;
@@ -59,7 +59,11 @@ public class CRTiledMap {
Array tiles = elemData.getChildrenByName("tile");
for (int i = 0; i < tiles.size; i++) {
- result.map[i % width][i / width] = tiles.get(i).getInt("gid");
+ int gid = tiles.get(i).getInt("gid");
+ int tx = i % width;
+ int ty = height - i / width - 1;
+
+ result.map[tx][ty] = gid;
}
}
else if(elemLayer.getAttribute("name").equalsIgnoreCase("Interaktionen"))
@@ -69,7 +73,11 @@ public class CRTiledMap {
Array tiles = elemData.getChildrenByName("tile");
for (int i = 0; i < tiles.size; i++) {
- result.interaktionen[i % width][i / width] = tiles.get(i).getInt("gid");
+ int gid = tiles.get(i).getInt("gid");
+ int tx = i % width;
+ int ty = height - i / width - 1;
+
+ result.interaktionen[tx][ty] = gid;
}
}
else
diff --git a/core/src/de/samdev/colorrunner/game/world/map/provider/EndlessMapProvider.java b/core/src/de/samdev/colorrunner/game/world/map/provider/EndlessMapProvider.java
index 8743d30..8b20077 100644
--- a/core/src/de/samdev/colorrunner/game/world/map/provider/EndlessMapProvider.java
+++ b/core/src/de/samdev/colorrunner/game/world/map/provider/EndlessMapProvider.java
@@ -1,5 +1,6 @@
package de.samdev.colorrunner.game.world.map.provider;
+import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
@@ -45,14 +46,21 @@ public class EndlessMapProvider extends MapProvider {
int end = sections.get(i).end;
if(start <= x && end > x){
- if( sections.get(i).crTiledMap.interaktionen[x - start][y] == CRTiledMap.GID_INTER_UP)
+ if (y < 0) return TriggerType.NOTHING;
+ if (y >= sections.get(i).crTiledMap.getHeight()) return TriggerType.NOTHING;
+
+ if( sections.get(i).crTiledMap.interaktionen[x - start][y] == CRTiledMap.GID_INTER_UP)
return TriggerType.RUNTOP;
- else if( sections.get(i).crTiledMap.interaktionen[x - start][y] == CRTiledMap.GID_INTER_DOWN)
+ else if( sections.get(i).crTiledMap.interaktionen[x - start][y] == CRTiledMap.GID_INTER_DOWN)
return TriggerType.RUNTOP;
- else if( sections.get(i).crTiledMap.interaktionen[x - start][y] == CRTiledMap.GID_INTER_RIGHT)
+ else if( sections.get(i).crTiledMap.interaktionen[x - start][y] == CRTiledMap.GID_INTER_RIGHT)
return TriggerType.FLY;
- else
- return TriggerType.NOTHING;
+ else if(sections.get(i).crTiledMap.interaktionen[x][y] == 0)
+ return TriggerType.NOTHING;
+ else {
+ Gdx.app.error("MapProvider", "Unknown trigger: " + sections.get(i).crTiledMap.interaktionen[x][y]);
+ return TriggerType.NOTHING;
+ }
}
}
return TriggerType.NOTHING;
@@ -80,7 +88,7 @@ public class EndlessMapProvider extends MapProvider {
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
float px = posX * FloorTileEntity.FLOORTILE_WIDTH + x * FloorTileEntity.FLOORTILE_WIDTH;
- float py = (height - y) * FloorTileEntity.FLOORTILE_WIDTH;
+ float py = y * FloorTileEntity.FLOORTILE_WIDTH;
CRGameEntity e = CRTiledMap.CreateTile(world, map.getGID(x, y), px, py);
if (e != null) world.addEntity(e);
diff --git a/core/src/de/samdev/colorrunner/game/world/map/provider/StaticMapProvider.java b/core/src/de/samdev/colorrunner/game/world/map/provider/StaticMapProvider.java
index 46e2067..2ee1a01 100644
--- a/core/src/de/samdev/colorrunner/game/world/map/provider/StaticMapProvider.java
+++ b/core/src/de/samdev/colorrunner/game/world/map/provider/StaticMapProvider.java
@@ -1,5 +1,6 @@
package de.samdev.colorrunner.game.world.map.provider;
+import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Rectangle;
import de.samdev.colorrunner.game.renderer.AbstractGameRenderer;
@@ -30,14 +31,24 @@ public class StaticMapProvider extends MapProvider {
@Override
public TriggerType getTrigger(int x, int y) {
- if(map.interaktionen[x][y] == CRTiledMap.GID_INTER_UP)
+ if (x < 0) return TriggerType.NOTHING;
+ if (y < 0) return TriggerType.NOTHING;
+ if (x >= map.getWidth()) return TriggerType.NOTHING;
+ if (y >= map.getHeight()) return TriggerType.NOTHING;
+
+ if(map.interaktionen[x][ y] == CRTiledMap.GID_INTER_UP)
return TriggerType.RUNTOP;
else if(map.interaktionen[x][y] == CRTiledMap.GID_INTER_DOWN)
return TriggerType.RUNBOTTOM;
else if(map.interaktionen[x][y] == CRTiledMap.GID_INTER_RIGHT)
return TriggerType.FLY;
- else
+ else if(map.interaktionen[x][y] == 0)
return TriggerType.NOTHING;
+ else
+ {
+ Gdx.app.error("MapProvider", "Unknown trigger: " + map.interaktionen[x][y]);
+ return TriggerType.NOTHING;
+ }
}
@Override
@@ -63,7 +74,7 @@ public class StaticMapProvider extends MapProvider {
for (int x = xstart; x < xend; x++) {
for (int y = 0; y < height; y++) {
float px = x * FloorTileEntity.FLOORTILE_WIDTH;
- float py = (height - y) * FloorTileEntity.FLOORTILE_WIDTH;
+ float py = y * FloorTileEntity.FLOORTILE_HEIGHT;
CRGameEntity e = CRTiledMap.CreateTile(world, map.getGID(x, y), px, py);
if (e != null) world.addEntity(e);