31 lines
677 B
JavaScript
31 lines
677 B
JavaScript
import { BaseEnemy } from './BaseEnemy.js';
|
|
|
|
export class ChaseEnemy extends BaseEnemy {
|
|
constructor(scene, x, y, player) {
|
|
super(scene, x, y, player, {
|
|
frameOffset: 0,
|
|
radius: 14,
|
|
hp: 40,
|
|
speed: 80,
|
|
xp: 15,
|
|
contactDamage: 12,
|
|
});
|
|
this._deathPulseColor = 0x00ff44;
|
|
this._deathSound = 'sfx-death-chaser';
|
|
}
|
|
|
|
update(delta) {
|
|
super.update(delta);
|
|
const angle = Phaser.Math.Angle.Between(this.x, this.y, this.player.x, this.player.y);
|
|
this.sprite.body.setVelocity(
|
|
Math.cos(angle) * this.speed,
|
|
Math.sin(angle) * this.speed
|
|
);
|
|
}
|
|
|
|
_die() {
|
|
this._gridDeathPulse();
|
|
super._die();
|
|
}
|
|
}
|