java-ascii-game/src/Player.java
2024-05-26 17:24:02 +02:00

34 lines
701 B
Java

import processing.core.PApplet;
public class Player extends Character implements Health {
int x, y;
int health;
int maxHealth = 20;
Player(PApplet window) {
super(window);
this.type = "@";
this.x = 4;
this.y = 4;
this.health = maxHealth;
}
public void damageEnemy(int damage, Enemy enemy) {
enemy.damage(damage);
}
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;
}
}
}