Generated particles need not have any randomness in either angle or velocity.
[supertux.git] / src / object / particles.cpp
index 6ee3ab1..36d3b6e 100644 (file)
@@ -88,10 +88,13 @@ 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
-    particle->vel.x = (cos(angle)) * velocity;
-    particle->vel.y = (sin(angle)) * velocity;
+    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;
 
     particles.push_back(particle);
   }