From 2ace662b7f39c76d310f0c521f3bed585a289cd3 Mon Sep 17 00:00:00 2001 From: LMH Date: Mon, 15 Jul 2013 15:00:10 -1000 Subject: [PATCH] HeavyCoins make noise when they collide with solid objects. TODO: use a unique sound. --- src/object/coin.cpp | 9 +++++++++ src/object/coin_explode.cpp | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/object/coin.cpp b/src/object/coin.cpp index c87c9384f..37becc046 100644 --- a/src/object/coin.cpp +++ b/src/object/coin.cpp @@ -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); } } diff --git a/src/object/coin_explode.cpp b/src/object/coin_explode.cpp index e1853cf73..35bca7db2 100644 --- a/src/object/coin_explode.cpp +++ b/src/object/coin_explode.cpp @@ -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)))); -- 2.11.0