Shake monsters when damaged
authorMegaBrutal <code+git@megabrutal.com>
Fri, 29 Dec 2017 22:55:00 +0000 (23:55 +0100)
committerMegaBrutal <code+git@megabrutal.com>
Fri, 29 Dec 2017 22:55:00 +0000 (23:55 +0100)
Monsters should give some feedback when they are damaged to let the
player know that shooting them has effect.

modified:   ld40.js

ld40.js

diff --git a/ld40.js b/ld40.js
index e981a9ef0768c78a6868a9e8c0ffdbae3f066660..53e41f87ce314147e88d5301a5a3b91ea399bfc0 100644 (file)
--- a/ld40.js
+++ b/ld40.js
                 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();