aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/Actor.java
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-02-10 19:06:21 +0100
committerNao Pross <naopross@thearcway.org>2018-02-10 19:06:21 +0100
commit21b40a8dcc55b3ec365b4a33f08310957155b50d (patch)
treefe839a00556d2120f52a115cdd3efa54f4de32fc /src/main/java/Actor.java
parentImplement actor, create player (diff)
downloadSubconscious-old-21b40a8dcc55b3ec365b4a33f08310957155b50d.tar.gz
Subconscious-old-21b40a8dcc55b3ec365b4a33f08310957155b50d.zip
Threaded double buffered rendering
Other changes: - Tabs < Spaces - Add jar manifest configuration to gradle.build
Diffstat (limited to 'src/main/java/Actor.java')
-rw-r--r--src/main/java/Actor.java107
1 files changed, 52 insertions, 55 deletions
diff --git a/src/main/java/Actor.java b/src/main/java/Actor.java
index 3d81d7c..7ebdf7f 100644
--- a/src/main/java/Actor.java
+++ b/src/main/java/Actor.java
@@ -3,59 +3,56 @@ import java.awt.Point;
public class Actor {
- public enum Type {
- PLAYER, ENEMY
- }
-
-
- public final String name;
- public final Type type;
- protected final int MAXHP;
- protected int hp;
- protected int x, y;
- protected Dimension gridSize;
-
- public Actor(String name, int MAXHP, Type type) {
- this.name = name;
- this.type = type;
- this.MAXHP = MAXHP;
- this.hp = this.MAXHP;
- }
-
- public void damage(int dmg) {
- this.hp = this.hp - dmg;
- if (this.hp < 0) {
- this.hp = 0;
- }
- }
-
- public void heal(int life) {
- this.hp = this.hp + life;
- if (this.hp > this.MAXHP) {
- this.hp = this.MAXHP;
- }
- }
-
- public boolean move(int x, int y) {
- if (x < this.gridSize.width && y < this.gridSize.height && x > 0 && y > 0) {
- this.x = x;
- this.y = y;
- return true;
- } else {
- return false;
- }
- }
-
- public int getHp() {
- return this.hp;
- }
-
- public int getX() {
- return this.x;
- }
-
- public int getY() {
- return this.y;
- }
-
+ public enum Type {
+ PLAYER, ENEMY
+ }
+
+ public final String name;
+ public final Type type;
+ protected final int MAXHP;
+ protected int hp;
+ protected int x, y;
+ protected Dimension gridSize;
+
+ public Actor(String name, int MAXHP, Type type) {
+ this.name = name;
+ this.type = type;
+ this.MAXHP = MAXHP;
+ this.hp = this.MAXHP;
+ }
+
+ public void damage(int dmg) {
+ this.hp = this.hp - dmg;
+ if (this.hp < 0) {
+ this.hp = 0;
+ }
+ }
+
+ public void heal(int life) {
+ this.hp = this.hp + life;
+ if (this.hp > this.MAXHP) {
+ this.hp = this.MAXHP;
+ }
+ }
+
+ public boolean move(int x, int y) {
+ if (x < this.gridSize.width && y < this.gridSize.height && x > 0 && y > 0) {
+ this.x = x;
+ this.y = y;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public int getHp() {
+ return this.hp;
+ }
+
+ public int getX() {
+ return this.x; }
+
+ public int getY() {
+ return this.y;
+ }
}