pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src/worldobjs snow_generator.cxx,1.5,1.6


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/worldobjs snow_generator.cxx,1.5,1.6 snow_generator.hxx,1.5,1.6
Date: 19 Feb 2003 17:17:04 -0000

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

Modified Files:
        snow_generator.cxx snow_generator.hxx 
Log Message:
- added intesity to snow generator
- misc other stuff


Index: snow_generator.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobjs/snow_generator.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- snow_generator.cxx  28 Dec 2002 16:10:18 -0000      1.5
+++ snow_generator.cxx  19 Feb 2003 17:17:01 -0000      1.6
@@ -17,14 +17,19 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include <math.h>
+#include <iostream>
+#include "../math.hxx"
 #include "../world.hxx"
 #include "../particles/snow_particle_holder.hxx"
+#include "../worldobjsdata/snow_generator_data.hxx"
 #include "snow_generator.hxx"
 
 namespace WorldObjs {
 
-SnowGenerator::SnowGenerator()
+SnowGenerator::SnowGenerator (const WorldObjsData::SnowGeneratorData& data_)
 {
+  intensity = data_.intensity;
 }
 
 SnowGenerator::~SnowGenerator()
@@ -34,9 +39,21 @@
 void 
 SnowGenerator::update()
 {
-  world->get_snow_particle_holder()->add_particle(rand() % world->get_width(), 
-32);
-  world->get_snow_particle_holder()->add_particle(rand() % world->get_width(), 
-32);
-  world->get_snow_particle_holder()->add_particle(rand() % world->get_width(), 
-32, true);
+  for(int i = 0; i < floor(intensity); ++i)
+    {
+      if (rand() % 3 != 0)
+        world->get_snow_particle_holder()->add_particle(rand() % 
world->get_width(), -32, false);
+      else
+        world->get_snow_particle_holder()->add_particle(rand() % 
world->get_width(), -32, true);
+    }
+
+  if ((intensity - (int)intensity) > Math::frand())
+    {
+      if (rand() % 3 != 0)
+        world->get_snow_particle_holder()->add_particle(rand() % 
world->get_width(), -32, false);
+      else
+        world->get_snow_particle_holder()->add_particle(rand() % 
world->get_width(), -32, true);
+    }
 }
 
 void

Index: snow_generator.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobjs/snow_generator.hxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- snow_generator.hxx  1 Oct 2002 19:53:46 -0000       1.5
+++ snow_generator.hxx  19 Feb 2003 17:17:01 -0000      1.6
@@ -22,14 +22,18 @@
 
 #include "../worldobj.hxx"
 
+namespace WorldObjsData {
+class SnowGeneratorData;
+}
+
 namespace WorldObjs {
 
 class SnowGenerator : public WorldObj
 {
 private:
-
+  float intensity;
 public:
-  SnowGenerator ();
+  SnowGenerator (const WorldObjsData::SnowGeneratorData& data_);
   ~SnowGenerator ();
 
   /** fill the screen with snow flocks */





reply via email to

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