public void setHp(int hp) { this.hp = hp; if (this.hp < 1) { this.hp = 0; setDead(true); } }
public Creature(Position pos, Map world) { setMoving(5); attacked = false; setTarget(null); setTile(world.tileAt(pos)); getTile().setC(this); this.setPos(pos); this.world = world; setHp(DEF_HP); setMp(DEF_MP); setMaxhp(DEF_HP); setMaxmp(DEF_MP); setSpeed(DEF_SPEED); setActive(false); setDead(false); damageTaken = new Label(""); damageTaken.setForeground(Color.red); healTaken = new Label(""); healTaken.setForeground(Color.green); }
public void takeDamage(int dmg) { // battle text points damageTaken.setText("-" + Integer.toString(dmg)); damageTaken.pack(); deltaDamage = show_damage_time; int x = getPos().getX() - targeted.getPos().getX(); int y = getPos().getY() - targeted.getPos().getY(); int center_x = 7 * 50 + 10; int center_y = 5 * 50 + 10; x = center_x + x * 50 + 30; y = center_y + y * 50 + 10; damageTaken.setLocation(x, y); this.hp -= dmg; if (this.hp < 1) { this.hp = 0; setDead(true); } }