summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/subconscious/Map.java1
-rw-r--r--src/subconscious/Tile.java5
-rw-r--r--src/subconscious/graphics/MapScene.java28
-rw-r--r--src/subconscious/graphics/Sprite.java23
4 files changed, 36 insertions, 21 deletions
diff --git a/src/subconscious/Map.java b/src/subconscious/Map.java
index 4fd4d00..5f15a52 100644
--- a/src/subconscious/Map.java
+++ b/src/subconscious/Map.java
@@ -133,6 +133,7 @@ public class Map {
return getTile(pos.x, pos.y);
}
+ // TODO fix this garbage
public int getSize() {
return this.size.width;
}
diff --git a/src/subconscious/Tile.java b/src/subconscious/Tile.java
index 703b196..1bccdb2 100644
--- a/src/subconscious/Tile.java
+++ b/src/subconscious/Tile.java
@@ -1,6 +1,7 @@
package subconscious;
import java.util.ArrayList;
+import java.awt.Point;
public class Tile {
// TODO: create an EnumSet for other modifiers
@@ -103,6 +104,10 @@ public class Tile {
return this.y;
}
+ public Point getPoint() {
+ return new Point(this.x, this.y);
+ }
+
public void setSelected(boolean set) {
this.selected = set;
}
diff --git a/src/subconscious/graphics/MapScene.java b/src/subconscious/graphics/MapScene.java
index dde15c6..feb041a 100644
--- a/src/subconscious/graphics/MapScene.java
+++ b/src/subconscious/graphics/MapScene.java
@@ -32,7 +32,7 @@ import java.awt.geom.NoninvertibleTransformException;
@SuppressWarnings("serial")
public abstract class MapScene extends Scene {
- protected Map map;
+ protected volatile Map map;
// used for rendering
protected int tileSize;
@@ -75,7 +75,7 @@ public abstract class MapScene extends Scene {
/* get the coordinates of the tile on the screen at position screenPos
* if there is not tile under screenPos the return value is null
*/
- public Point tileAtCoordinates(Point screenPos) {
+ protected Point tileAtCoordinates(Point screenPos) {
Rectangle mapRect = new Rectangle(0, 0, this.map.getSize(), this.map.getSize());
if (undoZoomTx == null || undoPanTx == null) {
@@ -97,6 +97,11 @@ public abstract class MapScene extends Scene {
return screenPos;
}
+
+ private void updateSprites() {
+ // TODO: update this.sprites to contain only the sprites that need
+ // to be rendered. I.E. in the rendering area after the transformation
+ }
private void renderTiles(Graphics2D g) {
for (Tile tile : this.game.getMap().getGrid()) {
@@ -173,19 +178,6 @@ public abstract class MapScene extends Scene {
g.setFont(g.getFont().deriveFont(g.getFont().getSize()*2.0F));
for (Actor actor : this.map.getActors()) {
- if (actor.isEnemy()) {
- g.setColor(Palette.RED);
- } else {
- g.setColor(Palette.BLUE);
- }
-
- g.fillRect(
- this.tileSize * actor.getX() + this.tileSize/5,
- this.tileSize * actor.getY() + this.tileSize/5,
- 3 * this.tileSize / 5,
- 3 * this.tileSize / 5
- );
-
// name
g.setColor(Palette.BLACK);
g.drawString(
@@ -214,11 +206,7 @@ public abstract class MapScene extends Scene {
@Override
protected void render(Graphics2D g) {
- // TODO: remove, map should never be NULL
- // this is an old piece of code used for MapEditor
- if (this.map == null) {
- return;
- }
+ assert this.map != null;
// clear canvas
g.setColor(Palette.BLACK);
diff --git a/src/subconscious/graphics/Sprite.java b/src/subconscious/graphics/Sprite.java
index ed048da..7c0b9eb 100644
--- a/src/subconscious/graphics/Sprite.java
+++ b/src/subconscious/graphics/Sprite.java
@@ -14,12 +14,25 @@ public class Sprite {
protected int width, height;
protected int dx, dy;
+ protected boolean loaded = true;
+
public Sprite(Actor actor) {
this.actor = actor;
}
public void render(Graphics2D g) {
-
+ if (actor.isEnemy()) {
+ g.setColor(Palette.RED);
+ } else {
+ g.setColor(Palette.BLUE);
+ }
+
+ g.fillRect(
+ this.width/5,
+ this.height/5,
+ this.width - this.width/5 * 2,
+ this.height - this.height/5 * 2
+ );
}
public void update() {
@@ -27,7 +40,15 @@ public class Sprite {
y += dy;
}
+ public Actor getActor() {
+ return this.actor;
+ }
+
public Rectangle getRect() {
return new Rectangle(x, y, width, height);
}
+
+ public void load() { this.loaded = true; }
+ public void unload() { this.loaded = false; }
+ public boolean isLoaded() { return this.loaded; }
}