diff --git a/android/assets/map_pieces/p09.tmx b/android/assets/map_pieces/p09.tmx
index 7b2598c..1593f44 100644
--- a/android/assets/map_pieces/p09.tmx
+++ b/android/assets/map_pieces/p09.tmx
@@ -459,6 +459,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -505,38 +525,18 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android/assets/map_pieces/p9.tmx b/android/assets/map_pieces/p9.tmx
deleted file mode 100644
index 1593f44..0000000
--- a/android/assets/map_pieces/p9.tmx
+++ /dev/null
@@ -1,648 +0,0 @@
-
-
diff --git a/core/src/de/samdev/colorrunner/game/renderer/AbstractGameRenderer.java b/core/src/de/samdev/colorrunner/game/renderer/AbstractGameRenderer.java
index dff6bea..548f378 100644
--- a/core/src/de/samdev/colorrunner/game/renderer/AbstractGameRenderer.java
+++ b/core/src/de/samdev/colorrunner/game/renderer/AbstractGameRenderer.java
@@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
+import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector3;
public abstract class AbstractGameRenderer {
@@ -49,6 +50,10 @@ public abstract class AbstractGameRenderer {
}
}
+ public Rectangle getCamViewRectangle() {
+ return new Rectangle(cam.position.x - cam.viewportWidth/2, cam.position.y - cam.viewportHeight/2, cam.viewportWidth, cam.viewportHeight);
+ }
+
public void resize(float width, float height) {
float cam_width = (width / height) * GAME_HEIGHT;
@@ -76,8 +81,8 @@ public abstract class AbstractGameRenderer {
}
protected void renderDebug(String s) {
- Vector3 coords = cam.unproject(new Vector3(10, 10 + debugTextCount++ * 20, 0));
- font.draw(fontBatch, s, coords.x, coords.y);
+ Vector3 coords = cam.unproject(new Vector3(10, 10, 0));
+ font.draw(fontBatch, s, coords.x, coords.y - debugTextCount++ * 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 8b1f213..a20b212 100644
--- a/core/src/de/samdev/colorrunner/game/renderer/CRGameRenderer.java
+++ b/core/src/de/samdev/colorrunner/game/renderer/CRGameRenderer.java
@@ -22,32 +22,16 @@ public class CRGameRenderer extends AbstractGameRenderer {
@Override
public void doRender() {
updateCameraOffset(gameworld.player.bounds.x);
+ gameworld.camViewBoundaries = getCamViewRectangle();
- 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 + "%)");
- endDebug();
+ renderDebugInfo();
+
+ renderMain();
+
+ renderDebugBoxes();
+ }
- //################################################################################
-
- spriteBatch.begin();
-
- for (CRGameEntity e : gameworld.entities) {
- spriteBatch.draw(e.getTexture(), e.bounds.x, e.bounds.y, e.bounds.width, e.bounds.height);
- }
-
- //################################################################################
-
- 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();
-
- spriteBatch.end();
-
- //################################################################################
-
+ private void renderDebugBoxes() {
shapeRenderer.begin(ShapeType.Line);
shapeRenderer.setColor(1, 0, 1, 1);
@@ -64,4 +48,30 @@ public class CRGameRenderer extends AbstractGameRenderer {
shapeRenderer.end();
}
+
+ private void renderMain() {
+ spriteBatch.begin();
+
+ for (CRGameEntity e : gameworld.entities) {
+ spriteBatch.draw(e.getTexture(), e.bounds.x, e.bounds.y, e.bounds.width, e.bounds.height);
+ }
+
+
+ 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();
+
+ spriteBatch.end();
+ }
+
+ 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);
+ endDebug();
+ }
}
diff --git a/core/src/de/samdev/colorrunner/game/world/CRGameWorld.java b/core/src/de/samdev/colorrunner/game/world/CRGameWorld.java
index 66625b9..c11ba13 100644
--- a/core/src/de/samdev/colorrunner/game/world/CRGameWorld.java
+++ b/core/src/de/samdev/colorrunner/game/world/CRGameWorld.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import de.samdev.colorrunner.game.renderer.AbstractGameRenderer;
@@ -28,6 +29,8 @@ public class CRGameWorld implements GameInputListener {
private float mapRightBoundary = 0;
+ public Rectangle camViewBoundaries = new Rectangle();
+
public CRGameWorld() {
addEntity(player = new PlayerEntity(this, 40, 290));
@@ -38,8 +41,13 @@ public class CRGameWorld implements GameInputListener {
public void update(float delta) {
fps.Inc();
- for (CRGameEntity ent : entities) {
- ent.update(delta);
+ for (int i = entities.size()-1; i >= 0; i--) {
+ CRGameEntity ent = entities.get(i);
+
+ if (ent.active)
+ ent.update(delta);
+ else
+ entities.remove(i);
}
expandMap();
diff --git a/core/src/de/samdev/colorrunner/game/world/entities/CRGameEntity.java b/core/src/de/samdev/colorrunner/game/world/entities/CRGameEntity.java
index 85a49a2..243399f 100644
--- a/core/src/de/samdev/colorrunner/game/world/entities/CRGameEntity.java
+++ b/core/src/de/samdev/colorrunner/game/world/entities/CRGameEntity.java
@@ -12,6 +12,7 @@ public abstract class CRGameEntity {
protected CRGameWorld world;
public Rectangle bounds = new Rectangle();
+ public boolean active = false; // true ::= marked for removal
protected Vector2 tmp_pos = new Vector2();
@@ -20,6 +21,8 @@ public abstract class CRGameEntity {
}
public CRGameEntity(CRGameWorld _owner, float x, float y, float width, float height) {
+ active = true;
+
bounds = new Rectangle(x, y, width, height);
world = _owner;
}
@@ -28,6 +31,10 @@ public abstract class CRGameEntity {
return bounds.getPosition(tmp_pos);
}
+ public void remove() {
+ active = false;
+ }
+
public abstract void update(float delta);
public abstract Texture getTexture();
diff --git a/core/src/de/samdev/colorrunner/game/world/entities/gameentities/floor/FloorTileEntity.java b/core/src/de/samdev/colorrunner/game/world/entities/gameentities/floor/FloorTileEntity.java
index 830d7cd..c398e23 100644
--- a/core/src/de/samdev/colorrunner/game/world/entities/gameentities/floor/FloorTileEntity.java
+++ b/core/src/de/samdev/colorrunner/game/world/entities/gameentities/floor/FloorTileEntity.java
@@ -16,7 +16,8 @@ public abstract class FloorTileEntity extends StaticEntity {
@Override
public void update(float delta) {
- // nothing
+ if (bounds.x < world.camViewBoundaries.x - 512)
+ remove();
}
@Override