]> git.mxchange.org Git - quix0rs-blobwars.git/blobdiff - src/particles.cpp
Added .gitignore to ignore certain files + fixed access rights on Makefile* as
[quix0rs-blobwars.git] / src / particles.cpp
index 7e6979a6d022dc766a48ce7065a6bd88054f3b81..79f71efcab2b5f0c1fbfa46be6e70c3063861ebd 100644 (file)
@@ -1,5 +1,6 @@
 /*
-Copyright (C) 2004 Parallel Realities
+Copyright (C) 2004-2011 Parallel Realities
+Copyright (C) 2011-2015 Perpendicular Dimensions
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
@@ -22,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 void addWindParticles()
 {
-       int c = graphics.white;
+       int c;
        float x, y, dx, dy;
        
 
@@ -62,16 +63,15 @@ void addColorParticles(float x, float y, int amount, int color)
        for (int i = 0 ; i < amount ; i++)
        {
                if (color == -1)
-               {
                        c = Math::prand() % 5;
-                       switch (c)
-                       {
-                               case 0: c = graphics.white; break;
-                               case 1: c = graphics.grey; break;
-                               case 2: c = graphics.blue; break;
-                               case 3: c = graphics.cyan; break;
-                               case 4: c = graphics.red; break;
-                       }
+
+               switch (c)
+               {
+                       case 0: c = graphics.white; break;
+                       case 1: c = graphics.grey; break;
+                       case 2: c = graphics.blue; break;
+                       case 3: c = graphics.cyan; break;
+                       case 4: c = graphics.red; break;
                }
 
                dx = Math::rrand(-30, 30); dx /= 30;
@@ -87,14 +87,17 @@ void addFireTrailParticle(float x, float y)
 
 void addFireParticles(float x, float y, int amount)
 {
-       map.addParticle(x + Math::rrand(-2, 2), y + Math::rrand(-2, 2), 0, 1, Math::rrand(5, 30), graphics.red, graphics.getSprite("Explosion", true), PAR_COLLIDES);
+       for (int i = 0 ; i < amount ; i++)
+       {
+               map.addParticle(x + Math::rrand(-2, 2), y + Math::rrand(-2, 2), 0, 1, Math::rrand(5, 30), graphics.red, graphics.getSprite("Explosion", true), PAR_COLLIDES);
+       }
 }
 
 void addBubble(float x, float y)
 {
        if ((Math::prand() % 50) == 0)
        {
-               map.addParticle(x + Math::prand() % BRICKSIZE, y + 19, 0, Math::rrand(-3, -1), Math::rrand(30, 90), graphics.red, graphics.getSprite("Bubble", true), PAR_COLLIDES + PAR_WEIGHTLESS);
+               map.addParticle(x + Math::prand() % BRICKSIZE, y + 19, 0, Math::rrand(-3, -1), Math::rrand(30, 90), graphics.red, graphics.getSprite("Bubble", true), PAR_COLLIDES | PAR_WEIGHTLESS | PAR_LIQUID);
        }
 }
 
@@ -136,7 +139,7 @@ void addTeleportParticles(float x, float y, int amount, int soundToPlay)
 
        if (soundToPlay != -1)
        {
-               audio.playSound(soundToPlay, CH_SPAWN);
+               audio.playSound(soundToPlay, CH_SPAWN, x);
        }
 }
 
@@ -187,6 +190,14 @@ void doParticles()
                        }
                }
 
+               if (particle->flags & PAR_LIQUID)
+               {
+                       if (!map.isLiquid(x, y))
+                       {
+                               particle->health = 0;
+                       }
+               }
+
                if (particle->health > 0)
                {
                        previous = particle;