Explicitly defined the angle used by Particles, used new definition for particles...
authorLMH <lmh.0013@gmail.com>
Sat, 29 Nov 2014 22:31:48 +0000 (12:31 -1000)
committerLMH <lmh.0013@gmail.com>
Sat, 29 Nov 2014 22:31:48 +0000 (12:31 -1000)
src/object/particles.cpp
src/object/player.cpp

index 1babe23..b468a93 100644 (file)
@@ -90,8 +90,9 @@ Particles::Particles(const Vector& epicenter, int min_angle, int max_angle,
 
     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;
+    // 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);
   }
index ef5b489..5f38c7f 100644 (file)
@@ -570,10 +570,9 @@ Player::handle_horizontal_input()
       // dust some particles
       Sector::current()->add_object(
         std::make_shared<Particles>(
-          Vector(dir == RIGHT ? get_bbox().p2.x : get_bbox().p1.x, get_bbox().p2.y),
-          dir == RIGHT ? 270+20 : 90-40, dir == RIGHT ? 270+40 : 90-20,
-          Vector(280, -260), Vector(0, 300), 3, Color(.4f, .4f, .4f), 3, .8f,
-          LAYER_OBJECTS+1));
+          Vector(dir == LEFT ? get_bbox().p2.x : get_bbox().p1.x, get_bbox().p2.y),
+          dir == LEFT ? 50 : -70, dir == LEFT ? 70 : -50, 260, 280,
+          Vector(0, 300), 3, Color(.4f, .4f, .4f), 3, .8f, LAYER_OBJECTS+1));
 
       ax *= 2.5;
     } else {
@@ -1342,14 +1341,12 @@ Player::collision_solid(const CollisionHit& hit)
       on_ground_flag = false;
       Sector::current()->add_object(std::make_shared<Particles>(
                                       Vector(get_bbox().p2.x, get_bbox().p2.y),
-                                      270+20, 270+40,
-                                      Vector(280, -260), Vector(0, 300), 3, Color(.4f, .4f, .4f), 3, .8f,
-                                      LAYER_OBJECTS+1));
+                                      50, 70, 260, 280, Vector(0, 300), 3,
+                                      Color(.4f, .4f, .4f), 3, .8f, LAYER_OBJECTS+1));
       Sector::current()->add_object(std::make_shared<Particles>(
                                       Vector(get_bbox().p1.x, get_bbox().p2.y),
-                                      90-40, 90-20,
-                                      Vector(280, -260), Vector(0, 300), 3, Color(.4f, .4f, .4f), 3, .8f,
-                                      LAYER_OBJECTS+1));
+                                      -70, -50, 260, 280, Vector(0, 300), 3,
+                                      Color(.4f, .4f, .4f), 3, .8f, LAYER_OBJECTS+1));
       Sector::current()->camera->shake(.1f, 0, 5);
     }