diff options
Diffstat (limited to 'src/main/java/WorldScene.java')
-rw-r--r-- | src/main/java/WorldScene.java | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/main/java/WorldScene.java b/src/main/java/WorldScene.java index 7888d6a..bde3a10 100644 --- a/src/main/java/WorldScene.java +++ b/src/main/java/WorldScene.java @@ -14,14 +14,12 @@ public class WorldScene extends Scene { private Map map; private int tileSize; - private int panX; - private int panY; + private int panX = 0; + private int panY = 0; public WorldScene(Dimension gridSize, int tileSize) { this.tileSize = tileSize; map = new Map(gridSize); - this.panX = 0; - this.panY = 0; // TODO remove hardcoded stuff @@ -50,8 +48,8 @@ public class WorldScene extends Scene { @Override public void pan(int x, int y) { - this.panX = this.panX + x; - this.panY = this.panY + y; + this.panX += x; + this.panY += y; } @Override @@ -107,12 +105,14 @@ public class WorldScene extends Scene { g2d.setColor(Palette.RED); break; } + int gap = this.tileSize / 10; g2d.fillRect( (this.tileSize * actor.getX()) + gap + this.panX, (this.tileSize * actor.getY()) + gap + this.panY, this.tileSize - gap * 2, this.tileSize - gap * 2 ); + if (!actor.isAlive()) { g2d.setColor(Palette.BLUE); g2d.fillRect( @@ -130,10 +130,12 @@ public class WorldScene extends Scene { this.updateTiles(); Tile tile = map.getTile( - (int) ((x+this.panX)/(double)this.tileSize) + this.sceneXOffset, - (int) ((y+this.panY)/(double)this.tileSize) + this.sceneYOffset + (int) ((x + this.panX)/(double)this.tileSize), + (int) ((y + this.panY)/(double)this.tileSize) ); + tile.selected = !tile.selected; + //TODO remove test stuff if (tile.getActor() != null) { Actor actor = tile.getActor(); @@ -142,10 +144,12 @@ public class WorldScene extends Scene { } } + // ugh, performance public void updateTiles() { for (Tile tile : this.map.grid) { tile.clearActor(); } + for (Actor actor : this.actors) { Tile tile = map.getTile(actor.getX(), actor.getY()); tile.setActor(actor); |