From c79eccf09042be0ccc7b579dbe033ca3739d45f4 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Thu, 13 Dec 2018 00:37:08 +0100 Subject: Change Tile.loaded to Tile.active --- src/subconscious/graphics/MapScene.java | 14 ++++++++------ 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; } } -- cgit v1.2.1