Shake monsters when damaged
[ld40.git] / ld40.js
diff --git a/ld40.js b/ld40.js
index f7954c2a7d4a0ae5239f12a0094744b2cafe8b7b..53e41f87ce314147e88d5301a5a3b91ea399bfc0 100644 (file)
--- a/ld40.js
+++ b/ld40.js
                 }
             }
 
                 }
             }
 
+            kill() {
+                this.health = 0;
+                this.healthBar.update(this.love, this.maxHealth, this.health);
+                super.kill();
+            }
+
             loveUp() {
                 this.love++
                 this.maxHealth += this.love;
             loveUp() {
                 this.love++
                 this.maxHealth += this.love;
                 game.physics.arcade.enable(this);
             }
 
                 game.physics.arcade.enable(this);
             }
 
+            damage(amount) {
+                super.damage(amount);
+                if (this.alive) { game.add.tween(this).to({ x: this.x + (Math.random() - 0.5) * 10 }, 10, Phaser.Easing.Sinusoidal.InOut, true, 0, 8, true); }
+            }
+
             kill() {
                 super.kill();
                 player.loveUp();
             kill() {
                 super.kill();
                 player.loveUp();