}
}, false);
+ function sign(n) {
+ if (n >= 0) { return 1 } else { return -1 };
+ }
class Player extends Phaser.Text {
constructor(x, y) {
this.lasttime_shoot = 0;
this.lasttime_mode = 0;
this.lasttime_damage = 0;
- this.speed = 150;
+ this.speed = SPEED_PLAYER;
this.switchmode(MODE_DETERMINATION);
this.weapon = new JusticeBlaster(game, this);
this.weapon.bulletSpeed = SPEED_PPROJECTILE;
}
}
+ 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();
nexttime_determination = Math.random() * WAIT_DETERMINATION;
monsters = game.add.group();
- monsters.add(new Monster(400, 500));
- monsters.children.forEach(function(monster) { monster.enablePhysics(); });
- nexttime_monsterspawn = WAIT_MONSTERSPAWN;
+ nexttime_monsterspawn = WAIT_MONSTERSPAWN / 4;
player = new Player(game.world.width / 2, game.world.height / 2);
player.enablePhysics();
var monster = new Monster(Math.random() * game.world.width, Math.random() * game.world.height);
monster.enablePhysics();
monsters.add(monster);
- nexttime_monsterspawn = game.time.now + (WAIT_MONSTERSPAWN / player.love) + (Math.random() * WAIT_MONSTERSPAWN);
+ var waittime = WAIT_MONSTERSPAWN - ((Math.random() * 2000) * player.love);
+ nexttime_monsterspawn = game.time.now + waittime;
+ console.log('Next monster in ' + waittime);
}
if ((game.time.now - player.lastmovetime) > WAIT_KEY) player.body.velocity.x = player.body.velocity.y = 0;