From 1987f42e5554996e5f765612bbcdc0737e108e12 Mon Sep 17 00:00:00 2001 From: mafaldo Date: Sat, 10 Feb 2018 21:42:50 +0100 Subject: tiles bound to actors, remove Player and Enemy --- src/main/java/Actor.java | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/main/java/Actor.java') 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; } -- cgit v1.2.1