pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/src/particles pingu_particle_holder.cxx,


From: torangan
Subject: [Pingus-CVS] CVS: Games/Pingus/src/particles pingu_particle_holder.cxx,1.4,1.5 smoke_particle_holder.cxx,1.3,1.4
Date: 5 Mar 2003 15:29:49 -0000

Update of /usr/local/cvsroot/Games/Pingus/src/particles
In directory dark:/tmp/cvs-serv407

Modified Files:
        pingu_particle_holder.cxx smoke_particle_holder.cxx 
Log Message:
fixed a stupid bug


Index: pingu_particle_holder.cxx
===================================================================
RCS file: 
/usr/local/cvsroot/Games/Pingus/src/particles/pingu_particle_holder.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- pingu_particle_holder.cxx   19 Feb 2003 09:50:36 -0000      1.4
+++ pingu_particle_holder.cxx   5 Mar 2003 15:29:47 -0000       1.5
@@ -24,6 +24,7 @@
 #include "../world.hxx"
 #include "pingu_particle_holder.hxx"
 
+#include <iostream>
 
 namespace Particles {
 
@@ -33,7 +34,7 @@
 }
 
 PinguParticleHolder::PinguParticle::PinguParticle (int x, int y)
-  : livetime(50 + (rand() % 50)),
+  : livetime(50 + (rand() % 75)),
     use_frame2((rand() % 5) == 0),
     pos(Vector(x, y)),
     velocity(Vector(Math::frand() * 7 - 3.5, Math::frand() * -7))
@@ -51,20 +52,23 @@
 PinguParticleHolder::add_particle (int x, int y)
 {
   int i = 0;
+  
   // fill gaps from dead entries
-  for (std::vector<PinguParticle>::iterator it=particles.begin(); i < 50 && it 
!= particles.end(); ++i, ++it)
+  for (std::vector<PinguParticle>::iterator it=particles.begin(); it != 
particles.end(); ++it)
     {
       if (!it->livetime)
         {
           *it = PinguParticle(x, y);
-          break;
+          ++i;
         }
     }
   
+  // allocate space for all remaining particles at once
+  particles.reserve(particles.size() + 50 - i);
+    
   // create remaining entries
   for (; i < 50; ++i)
     particles.push_back(PinguParticle(x, y));
-
 }
 
 void

Index: smoke_particle_holder.cxx
===================================================================
RCS file: 
/usr/local/cvsroot/Games/Pingus/src/particles/smoke_particle_holder.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- smoke_particle_holder.cxx   19 Feb 2003 09:50:36 -0000      1.3
+++ smoke_particle_holder.cxx   5 Mar 2003 15:29:47 -0000       1.4
@@ -48,8 +48,8 @@
     if (!it->livetime)
       {
         *it = SmokeParticle(x, y, vel_x, vel_y);
-             return;
-           }
+           return;
+         }
        
        // create new entry
   particles.push_back(SmokeParticle(x, y, vel_x, vel_y));
@@ -65,10 +65,10 @@
       if (!it->livetime)
         continue;
 
-           it->pos.x += it->velocity.x;
-           it->pos.y += it->velocity.y;
+      it->pos.x += it->velocity.x;
+         it->pos.y += it->velocity.y;
            
-           --it->livetime;
+         --it->livetime;
     }
 }
 
@@ -83,8 +83,8 @@
     
       if (!it->use_surf2)
         gc.draw(surf1, it->pos);
-           else
-             gc.draw(surf2, it->pos);
+         else
+           gc.draw(surf2, it->pos);
     }
 }
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]