HeavyCoins make noise when they collide with solid objects. TODO: use a unique sound.
authorLMH <lmh.0013@gmail.com>
Tue, 16 Jul 2013 01:00:10 +0000 (15:00 -1000)
committerLMH <lmh.0013@gmail.com>
Tue, 16 Jul 2013 01:00:10 +0000 (15:00 -1000)
src/object/coin.cpp
src/object/coin_explode.cpp

index c87c938..37becc0 100644 (file)
@@ -192,14 +192,23 @@ HeavyCoin::update(float elapsed_time)
 void
 HeavyCoin::collision_solid(const CollisionHit& hit)
 {
+  int clink_threshold = 100; // sets the minimum speed needed to result in collision noise
+  //TODO: colliding HeavyCoins should have their own unique sound
+
   if(hit.bottom) {
+    if(physic.get_velocity_y() > clink_threshold)
+      sound_manager->play("sounds/coin.wav");
     physic.set_velocity_y(0);
     physic.set_velocity_x(0);
   }
   if(hit.right || hit.left) {
+    if(physic.get_velocity_x() > clink_threshold || physic.get_velocity_x() < clink_threshold)
+      sound_manager->play("sounds/coin.wav");
     physic.set_velocity_x(-physic.get_velocity_x());
   }
   if(hit.top) {
+    if(physic.get_velocity_y() < clink_threshold)
+      sound_manager->play("sounds/coin.wav");
     physic.set_velocity_y(0);
   }
 }
index e1853cf..35bca7d 100644 (file)
@@ -32,7 +32,6 @@ CoinExplode::update(float )
   int mag = 100; // madnitude that coins are to be thrown
   int rand = 30; // max variation to be subtracted from magnitide
 
-  //TODO: this needs its own snazzy sound
   Sector::current()->add_object(new HeavyCoin(position, Vector (2.5,-4.5)*(mag-gameRandom.rand(rand))));
   Sector::current()->add_object(new HeavyCoin(position, Vector (2,-5)*(mag-gameRandom.rand(rand))));
   Sector::current()->add_object(new HeavyCoin(position, Vector (1.5,-5.5)*(mag-gameRandom.rand(rand))));