aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/WorldScene.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/WorldScene.java')
-rw-r--r--src/main/java/WorldScene.java31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/main/java/WorldScene.java b/src/main/java/WorldScene.java
index 829afbb..7d08077 100644
--- a/src/main/java/WorldScene.java
+++ b/src/main/java/WorldScene.java
@@ -21,7 +21,7 @@ public class WorldScene extends Scene {
// TODO remove hardcoded stuff
- Player player = new Player("pipo", gridSize);
+ Actor player = new Actor("pipo", 100, Actor.Type.PLAYER, gridSize);
this.actors.add(player);
}
@@ -79,7 +79,11 @@ public class WorldScene extends Scene {
for (Actor actor : this.actors) {
switch (actor.type) {
case PLAYER:
- g2d.setColor(Palette.ORANGE);
+ if (actor.isAlive()) {
+ g2d.setColor(Palette.ORANGE);
+ } else {
+ g2d.setColor(Palette.BLUE);
+ }
break;
case ENEMY:
g2d.setColor(Palette.RED);
@@ -87,8 +91,8 @@ public class WorldScene extends Scene {
}
int gap = this.tileSize / 10;
g2d.fillRect(
- (this.tileSize * actor.x) + gap,
- (this.tileSize * actor.y) + gap,
+ (this.tileSize * actor.getX()) + gap,
+ (this.tileSize * actor.getY()) + gap,
this.tileSize - gap * 2, this.tileSize - gap * 2
);
}
@@ -96,12 +100,27 @@ public class WorldScene extends Scene {
@Override
public void mouseClicked(int x, int y) {
+ this.updateTiles();
+
Tile tile = map.getTile(
(int) (x/(double)this.tileSize) + sceneXOffset,
(int) (y/(double)this.tileSize) + sceneYOffset
);
- // TODO find clicked actor
- tile.selected = !tile.selected;
+ //TODO remove test stuff
+ if (tile.getActor() != null) {
+ Actor actor = tile.getActor();
+ actor.damage(1000);
+ }
+ }
+
+ 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);
+ }
}
}