diff --git a/core/src/gdx/diablo/map/MapRenderer.java b/core/src/gdx/diablo/map/MapRenderer.java index 2c00d15a..acf11f23 100644 --- a/core/src/gdx/diablo/map/MapRenderer.java +++ b/core/src/gdx/diablo/map/MapRenderer.java @@ -11,6 +11,7 @@ import com.badlogic.gdx.math.GridPoint2; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Bits; +import com.badlogic.gdx.utils.IntMap; import java.util.Arrays; @@ -85,6 +86,8 @@ public class MapRenderer { // DT1 mainIndexes to not draw final Bits popped = new Bits(); + IntMap entities; + public MapRenderer(PaletteIndexedBatch batch, OrthographicCamera camera) { this.batch = batch; this.camera = camera; @@ -95,6 +98,10 @@ public class MapRenderer { camera.update(); } + public void setEntities(IntMap entities) { + this.entities = entities; + } + public void setMap(Map map) { if (this.map != map) { this.map = map; @@ -250,8 +257,10 @@ public class MapRenderer { break; case Map.SHADOW_OFFSET: break; - case Map.WALL_OFFSET: case Map.WALL_OFFSET + 1: case Map.WALL_OFFSET + 2: case Map.WALL_OFFSET + 3: + case Map.WALL_OFFSET: + drawEntities(batch, stx, sty); drawObjects(batch, zone, stx, sty); + case Map.WALL_OFFSET + 1: case Map.WALL_OFFSET + 2: case Map.WALL_OFFSET + 3: drawWall(batch, tile, px, py); break; case Map.TAG_OFFSET: @@ -287,6 +296,17 @@ public class MapRenderer { batch.draw(texture, px, py, texture.getRegionWidth() + 1, texture.getRegionHeight() + 1); } + void drawEntities(PaletteIndexedBatch batch, int stx, int sty) { + if (entities == null) return; + for (Entity entity : entities.values()) { + Vector3 position = entity.position(); + if ((stx <= position.x && position.x < stx + Tile.SUBTILE_SIZE) + && (sty <= position.y && position.y < sty + Tile.SUBTILE_SIZE)) { + entity.draw(batch); + } + } + } + void drawObjects(PaletteIndexedBatch batch, Map.Zone zone, int stx, int sty) { for (Entity entity : zone.entities) { Vector3 position = entity.position(); diff --git a/core/src/gdx/diablo/screen/GameScreen.java b/core/src/gdx/diablo/screen/GameScreen.java index c01cb504..0575bbda 100644 --- a/core/src/gdx/diablo/screen/GameScreen.java +++ b/core/src/gdx/diablo/screen/GameScreen.java @@ -403,14 +403,14 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable player.drawDebug(Diablo.shapes); Diablo.shapes.end(); - b.setProjectionMatrix(camera.combined); - b.begin(); + //b.setProjectionMatrix(camera.combined); + //b.begin(); - for (Player p : entities.values()) { - p.draw(b); - } + //for (Player p : entities.values()) { + // p.draw(b); + //} - b.end(); + //b.end(); b.setProjectionMatrix(Diablo.viewport.getCamera().combined); //Diablo.shapes.setAutoShapeType(true); @@ -436,6 +436,7 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable //camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); mapRenderer = new MapRenderer(Diablo.batch, camera); mapRenderer.setMap(map); + mapRenderer.setEntities(entities); mapRenderer.resize(); GridPoint2 origin = map.find(Map.ID.TOWN_ENTRY_1);