aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/WorldScene.java
diff options
context:
space:
mode:
authormafaldo <mafaldo@heavyhammer.home>2018-02-10 15:12:05 +0100
committermafaldo <mafaldo@heavyhammer.home>2018-02-10 15:12:05 +0100
commit0e8ebd8803718b37e9141649c6d8eb7036ec85ed (patch)
tree5b952c80b9d0616cf0bc7ba4243561352482e957 /src/main/java/WorldScene.java
parentSwitch to gradle, update gitignore (diff)
downloadSubconscious-old-0e8ebd8803718b37e9141649c6d8eb7036ec85ed.tar.gz
Subconscious-old-0e8ebd8803718b37e9141649c6d8eb7036ec85ed.zip
Implement actor, create player
Diffstat (limited to 'src/main/java/WorldScene.java')
-rw-r--r--src/main/java/WorldScene.java43
1 files changed, 36 insertions, 7 deletions
diff --git a/src/main/java/WorldScene.java b/src/main/java/WorldScene.java
index 6dff04a..2c11cba 100644
--- a/src/main/java/WorldScene.java
+++ b/src/main/java/WorldScene.java
@@ -3,10 +3,12 @@ import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
+import java.util.ArrayList;
+
public class WorldScene extends Scene {
- private Actor actors[];
+ private ArrayList<Actor> actors = new ArrayList<Actor>();
private Map map;
private int tileSize;
@@ -14,6 +16,9 @@ public class WorldScene extends Scene {
public WorldScene(Dimension gridSize, int tileSize) {
this.tileSize = tileSize;
map = new Map(gridSize);
+
+ Player player = new Player("pipo", gridSize);
+ this.actors.add(player);
}
@Override
@@ -21,12 +26,36 @@ public class WorldScene extends Scene {
Graphics2D g2d = (Graphics2D) g;
for (Tile tile : this.map.grid) {
- g2d.setColor(Color.GREEN);
- g2d.fillRect(
- this.tileSize * tile.x,
- this.tileSize * tile.y,
- this.tileSize, this.tileSize
- );
+ switch (tile.type) {
+ case GRASS:
+ g2d.setColor(Palette.GREEN);
+ break;
+ case WATER:
+ g2d.setColor(Palette.BLUE);
+ break;
+ }
+ g2d.fillRect(
+ this.tileSize * tile.x,
+ this.tileSize * tile.y,
+ this.tileSize, this.tileSize
+ );
}
+
+ for (Actor actor : this.actors) {
+ switch (actor.type) {
+ case PLAYER:
+ g2d.setColor(Palette.ORANGE);
+ break;
+ case ENEMY:
+ g2d.setColor(Palette.RED);
+ break;
+ }
+ int gap = this.tileSize/10;
+ g2d.fillRect(
+ (this.tileSize * actor.x) + gap,
+ (this.tileSize * actor.y) + gap,
+ this.tileSize-gap, this.tileSize-gap
+ );
+ }
}
}