diff options
author | Nao Pross <naopross@thearcway.org> | 2018-12-13 00:37:08 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2018-12-13 00:37:08 +0100 |
commit | c79eccf09042be0ccc7b579dbe033ca3739d45f4 (patch) | |
tree | 229d76183c2f05046b1d5e82c54673d93b3d1ff8 | |
parent | Fix Map.getSize() to return a Dimension (diff) | |
download | Subconscious-java-c79eccf09042be0ccc7b579dbe033ca3739d45f4.tar.gz Subconscious-java-c79eccf09042be0ccc7b579dbe033ca3739d45f4.zip |
Change Tile.loaded to Tile.active
-rw-r--r-- | src/subconscious/graphics/MapScene.java | 14 | ||||
-rw-r--r-- | src/subconscious/graphics/Sprite.java | 8 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/subconscious/graphics/MapScene.java b/src/subconscious/graphics/MapScene.java index c7f4167..c597d98 100644 --- a/src/subconscious/graphics/MapScene.java +++ b/src/subconscious/graphics/MapScene.java @@ -166,12 +166,14 @@ public abstract class MapScene extends Scene { private void renderSprites(Graphics2D g) { for (Sprite sprite : this.sprites) { - Rectangle rect = sprite.getRect(); - Graphics2D spriteGraphics = (Graphics2D) g.create( - rect.x, rect.y, rect.width, rect.height - ); - - sprite.render(spriteGraphics); + if (sprite.isActive()) { + Rectangle rect = sprite.getRect(); + Graphics2D spriteGraphics = (Graphics2D) g.create( + rect.x, rect.y, rect.width, rect.height + ); + + sprite.render(spriteGraphics); + } } // Draw actors diff --git a/src/subconscious/graphics/Sprite.java b/src/subconscious/graphics/Sprite.java index 7c0b9eb..b9e70d9 100644 --- a/src/subconscious/graphics/Sprite.java +++ b/src/subconscious/graphics/Sprite.java @@ -14,7 +14,7 @@ public class Sprite { protected int width, height; protected int dx, dy; - protected boolean loaded = true; + protected boolean active = true; public Sprite(Actor actor) { this.actor = actor; @@ -48,7 +48,7 @@ public class Sprite { 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; } + public void activate() { this.active = true; } + public void deactivate() { this.active = false; } + public boolean isActive() { return this.active; } } |