}
}, false);
+ function sign(n) {
+ if (n >= 0) { return 1 } else { return -1 };
+ }
class Player extends Phaser.Text {
constructor(x, y) {
}
}
+ kill() {
+ this.health = 0;
+ this.healthBar.update(this.love, this.maxHealth, this.health);
+ super.kill();
+ }
+
loveUp() {
this.love++
this.maxHealth += this.love;
this.weapon = new JusticeBlaster(game, this);
this.weapon.bulletSpeed = SPEED_MPROJECTILE;
this.weapon.trackSprite(this);
+ this.shaketween = game.add.tween(this).to({ x: this.x + (sign(Math.random() - 0.5)) * 5 }, 10, Phaser.Easing.Sinusoidal.InOut, false, 0, 8, true);
}
enablePhysics() {
game.physics.arcade.enable(this);
}
+ damage(amount) {
+ super.damage(amount);
+ if (this.alive) { this.shaketween.start(); }
+ }
+
kill() {
super.kill();
player.loveUp();