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 rain_particle_holder.cxx,1


From: torangan
Subject: [Pingus-CVS] CVS: Games/Pingus/src/particles rain_particle_holder.cxx,1.1,1.2 rain_particle_holder.hxx,1.1,1.2
Date: 31 Dec 2002 15:09:35 -0000

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

Modified Files:
        rain_particle_holder.cxx rain_particle_holder.hxx 
Log Message:
added optimization


Index: rain_particle_holder.cxx
===================================================================
RCS file: 
/usr/local/cvsroot/Games/Pingus/src/particles/rain_particle_holder.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- rain_particle_holder.cxx    28 Dec 2002 16:10:18 -0000      1.1
+++ rain_particle_holder.cxx    31 Dec 2002 15:09:33 -0000      1.2
@@ -37,7 +37,8 @@
 RainParticleHolder::RainParticleHolder ()
   : rain1_surf (PingusResource::load_surface("Particles/rain1", "pingus")),
     rain2_surf (PingusResource::load_surface("Particles/rain2", "pingus")),
-    rain_splash(PingusResource::load_surface("Particles/rain_splash", 
"pingus"))
+    rain_splash(PingusResource::load_surface("Particles/rain_splash", 
"pingus")),
+    world_width(1000.0f) // working default in case set_width() wasn't called
 {
 }
 
@@ -108,8 +109,8 @@
 {
   for (std::vector<RainParticle>::iterator it=particles.begin(); it != 
particles.end(); ++it)
     {
-      // skip dead particles
-      if (!it->alive)
+      // skip dead/invisible particles
+      if (!it->alive || it->pos.x > world_width)
         continue;
 
       if (it->splash)
@@ -120,6 +121,12 @@
         else
           gc.draw(rain1_surf, static_cast<int>(it->pos.x), 
static_cast<int>(it->pos.y - rain1_surf.get_height()));
     }
+}
+
+void
+RainParticleHolder::set_world_width(int width)
+{
+  world_width = width;
 }
 
 /* EOF */

Index: rain_particle_holder.hxx
===================================================================
RCS file: 
/usr/local/cvsroot/Games/Pingus/src/particles/rain_particle_holder.hxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- rain_particle_holder.hxx    28 Dec 2002 16:10:18 -0000      1.1
+++ rain_particle_holder.hxx    31 Dec 2002 15:09:33 -0000      1.2
@@ -46,6 +46,7 @@
   CL_Surface rain1_surf;
   CL_Surface rain2_surf;
   CL_Surface rain_splash;
+  float      world_width; // float since it's compared to a float value
 
   std::vector<RainParticle> particles;
   
@@ -61,6 +62,12 @@
 
   /// Draw the particle with the correct zoom resize
   void draw (GraphicContext& gc);
+
+  /** sets the width of the current world so that no particles
+    * are drawn outside the visible area (optimization).
+    * If this method is not called a default value of 1000 will
+    * be used to ensure that particles are drawn. */
+  void set_world_width(int width);
 
 private:
   RainParticleHolder (const RainParticleHolder&);




reply via email to

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