From 731aa57b3da0e89209ae2aaf19ee4960a7ae564f Mon Sep 17 00:00:00 2001
From: MegaBrutal <code+git@megabrutal.com>
Date: Wed, 3 Jan 2018 14:40:00 +0100
Subject: [PATCH] Add particle effect for player death

Added a simple particle effect to visualize how the player's soul
shatters upon death. The Game Over screen had to be delayed as the
player needs some time to see the particle effect.

	modified:   ld40.js
	new file:   soulbreak.png
	new file:   soulbreak.svg
---
 ld40.js       |  17 ++++++++++++++++-
 soulbreak.png | Bin 0 -> 387 bytes
 soulbreak.svg |   3 +++
 3 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 soulbreak.png
 create mode 100644 soulbreak.svg

diff --git a/ld40.js b/ld40.js
index 01a65ce..7bd582e 100644
--- a/ld40.js
+++ b/ld40.js
@@ -14,6 +14,7 @@
         const WAIT_MONSTERSHOOT		=    500;
         const WAIT_MONSTERSPAWN		=  20000;
         const WAIT_DETERMINATION	=   4000;
+        const WAIT_DEATH		=   4000;
         const WALL_THICKNESS		=     16;
         const WALL_BORDER		=      8;
         const WALL_BORDERBOTTOM		=     48;
@@ -48,11 +49,16 @@
                 this.lasttime_shoot = 0;
                 this.lasttime_mode = 0;
                 this.lasttime_damage = 0;
+                this.lasttime_death = 0;
                 this.speed = SPEED_PLAYER;
                 this.switchmode(MODE_DETERMINATION);
                 this.weapon = new JusticeBlaster(game, this);
                 this.weapon.bulletSpeed = SPEED_PPROJECTILE;
                 this.healthBar = new HealthBar(60, game.world.height - (WALL_BORDERBOTTOM / 2));
+                this.soulbreakEmitter = this.game.add.emitter(0, 0, 8);
+                this.soulbreakEmitter.gravity = 1000;
+                this.soulbreakEmitter.setXSpeed(-300, 300);
+                this.soulbreakEmitter.makeParticles('soulbreak');
             }
 
             enablePhysics() {
@@ -81,7 +87,10 @@
                 this.health = 0;
                 this.healthBar.update(this.love, this.maxHealth, this.health);
                 super.kill();
-                this.game.state.start('GameOver');
+                this.soulbreakEmitter.x = this.x;
+                this.soulbreakEmitter.y = this.y;
+                this.soulbreakEmitter.explode(2000, 8);
+                this.lasttime_death = this.game.time.now;
             }
 
             loveUp() {
@@ -267,6 +276,7 @@
                 game.load.image('monster', 'monster.png');
                 game.load.image('determination', 'determination.png');
                 game.load.image('projectile', 'projectile.png');
+                game.load.image('soulbreak', 'soulbreak.png');
 
             }
 
@@ -326,6 +336,11 @@
 
                 if ((game.time.now - player.lastmovetime) > WAIT_KEY) player.body.velocity.x = player.body.velocity.y = 0;
 
+                if ((!player.alive) && (game.time.now > (player.lasttime_death + WAIT_DEATH)))
+                {
+                    game.state.start('GameOver');
+                }
+
             }
         }
 
diff --git a/soulbreak.png b/soulbreak.png
new file mode 100644
index 0000000000000000000000000000000000000000..c8943ae08b468dd532849eb86eb4fd25307a12d3
GIT binary patch
literal 387
zcmeAS@N?(olHy`uVBq!ia0vp^oFL4?3?zm2ODh8@mUKs7M+SzC{oH>NS%G|oWRD<U
z28Jp%28M<f28Lfip@tU>45bDP46hOx7_4S6Fo+k-*%fF5l#mYa332@o1iyd(@9O&R
z<MW?^;eU7ce_!AKfBpc4GxX*?04ifF3GxeOaCmkj4a7<Ec6VXuV3qX%aySb-B8!2J
z`wha3+~uaTfr9KMp1!W^j~JO*l$qWuYdixA$$7dshHzX@PH<pza$|A`I;zUxF>8m)
zft!m~vTD3y2rp)CSMRx>2vn(B;u=wsl30>zm0Xkxq!^403@vmG40R2RLkvu;j7_Z!
zjI<35tqcs-I{pE94xu48KP5A*61RpsGA?dF4U!-mg7ec#$`gxH8OqDc^)mCai<1)z
ZQuXqS(r3T3kpe1W@O1TaS?83{1ORzYa!UXJ

literal 0
HcmV?d00001

diff --git a/soulbreak.svg b/soulbreak.svg
new file mode 100644
index 0000000..de67fc1
--- /dev/null
+++ b/soulbreak.svg
@@ -0,0 +1,3 @@
+<svg height="10" width="10">
+  <circle cx="5" cy="5" r="2.5" stroke="black" stroke-width="0" fill="red" />
+</svg> 
-- 
2.43.0