I have a Saw class that extends the Enemy class.
class Enemy {
int hp, atk, n;
float spd;
PVector pos = new PVector(random(width), random(height));
Enemy(int hp_, float spd_, int atk_, int n_) {
hp = hp_;
spd = spd_;
atk = atk_;
n = n_;
}
void update() {
PVector target = new PVector(vac.x, vac.y);
target.sub(pos);
target.setMag(spd);
pos.add(target);
subUpdate();
}
void display() {
image(enemy[n], pos.x, pos.y);
}
}
class Saw extends Enemy {
Saw() {
super(5, 4.0, 10, 0);
}
void subUpdate() {
}
}
In update()
I want to call the subUpdate()
method from the Saw class. Is this possible? I really can’t find any solution.