diff options
author | mafaldo <mafaldo@heavyhammer.home> | 2018-02-10 21:42:50 +0100 |
---|---|---|
committer | mafaldo <mafaldo@heavyhammer.home> | 2018-02-10 21:42:50 +0100 |
commit | 1987f42e5554996e5f765612bbcdc0737e108e12 (patch) | |
tree | 2f7f1538f272691c27d81ae21dc1c9493689f301 /src/main/java/Actor.java | |
parent | Add simple mouseclick listener to scenes (diff) | |
download | Subconscious-old-1987f42e5554996e5f765612bbcdc0737e108e12.tar.gz Subconscious-old-1987f42e5554996e5f765612bbcdc0737e108e12.zip |
tiles bound to actors, remove Player and Enemy
Diffstat (limited to 'src/main/java/Actor.java')
-rw-r--r-- | src/main/java/Actor.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/main/java/Actor.java b/src/main/java/Actor.java index 9f6f5e6..1e0ba80 100644 --- a/src/main/java/Actor.java +++ b/src/main/java/Actor.java @@ -1,5 +1,4 @@ import java.awt.Dimension; -import java.awt.Point; public class Actor { @@ -10,21 +9,24 @@ public class Actor { public final String name; public final Type type; - protected final int MAXHP; - protected int hp; - protected int x, y; - protected Dimension gridSize; + private boolean alive; + private final int MAXHP; + private int hp; + private int x, y; + private Dimension gridSize; - public Actor(String name, int MAXHP, Type type) { + public Actor(String name, int MAXHP, Type type, Dimension gridSize) { this.name = name; this.type = type; this.MAXHP = MAXHP; this.hp = this.MAXHP; + this.alive = true; } public void damage(int dmg) { this.hp = this.hp - dmg; - if (this.hp < 0) { + if (this.hp <= 0) { + this.alive = false; this.hp = 0; } } @@ -46,6 +48,10 @@ public class Actor { } } + public boolean isAlive() { + return alive; + } + public int getHp() { return this.hp; } |