Skip to content

Commit

Permalink
HeavyCoins make noise when they collide with solid objects. TODO: use…
Browse files Browse the repository at this point in the history
… a unique sound.
  • Loading branch information
LMH0013 committed Jul 16, 2013
1 parent 4f0d26a commit 2ace662
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/object/coin.cpp
Expand Up @@ -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);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/object/coin_explode.cpp
Expand Up @@ -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))));
Expand Down

0 comments on commit 2ace662

Please sign in to comment.