39 lines
846 B
Java
39 lines
846 B
Java
import processing.core.PApplet;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* This is the main player of the game we can move around with and interact.
|
|
*/
|
|
public class Player extends Fightable implements Health {
|
|
int x, y;
|
|
int health;
|
|
int maxHealth = 20;
|
|
List<Skill> skills = new ArrayList<Skill>();
|
|
|
|
Player(Fenster window) {
|
|
super(window);
|
|
this.type = "@";
|
|
this.x = 4;
|
|
this.y = 4;
|
|
this.health = maxHealth;
|
|
|
|
this.skills.add(new Tritt(window, this));
|
|
}
|
|
|
|
public void damage(int damage) {
|
|
health = health - damage;
|
|
if (health <= 0) {
|
|
window.println("dead");
|
|
}
|
|
}
|
|
|
|
public void heal(int healing) {
|
|
health = health + healing;
|
|
if (health > maxHealth) {
|
|
health = maxHealth;
|
|
}
|
|
}
|
|
}
|