Generated particles need not have any randomness in either angle or velocity.
authorLMH <lmh.0013@gmail.com>
Sat, 29 Nov 2014 22:41:37 +0000 (12:41 -1000)
committerLMH <lmh.0013@gmail.com>
Sat, 29 Nov 2014 22:41:37 +0000 (12:41 -1000)
src/object/fireworks.cpp
src/object/particles.cpp

index c557453..8ecbb0a 100644 (file)
@@ -49,7 +49,7 @@ Fireworks::update(float )
     //float green = 0.9;
     (void) red;
     (void) green;
-    sector->add_object(std::make_shared<Particles>(pos, 0, 360, Vector(140, 140),
+    sector->add_object(std::make_shared<Particles>(pos, 0, 360, 140, 140,
                                                    Vector(0, 0), 45, Color(red, green, 0), 3, 1.3f,
                                                    LAYER_FOREGROUND1+1));
     SoundManager::current()->play("sounds/fireworks.wav");
index b468a93..36d3b6e 100644 (file)
@@ -88,8 +88,10 @@ Particles::Particles(const Vector& epicenter, int min_angle, int max_angle,
     Particle* particle = new Particle;
     particle->pos = epicenter;
 
-    float velocity = graphicsRandom.rand(min_initial_velocity, max_initial_velocity);
-    float angle = graphicsRandom.rand(min_angle, max_angle) * (M_PI / 180);  // convert to radians
+    float velocity = (min_initial_velocity == max_initial_velocity) ? min_initial_velocity :
+                     graphicsRandom.rand(min_initial_velocity, max_initial_velocity);
+    float angle = (min_angle == max_angle) ? min_angle * (M_PI / 180) :
+                     graphicsRandom.rand(min_angle, max_angle) * (M_PI / 180);  // convert to radians
     // Note that angle defined as clockwise from vertical (up is zero degrees, right is 90 degrees)
     particle->vel.x = (sin(angle)) * velocity;
     particle->vel.y = (-cos(angle)) * velocity;