X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fobject%2Fcoin.cpp;h=c75312fb9adfb02633fcde87821be07c16202a41;hb=08ccb17345a52f5ffd8a5dd6ecf675cad55f16a7;hp=566d294899619b22b47aabce998f47bfa3402281;hpb=7eedaa580901ec970795fe66d6e7fa56349fb0a0;p=supertux.git diff --git a/src/object/coin.cpp b/src/object/coin.cpp index 566d29489..c75312fb9 100644 --- a/src/object/coin.cpp +++ b/src/object/coin.cpp @@ -38,11 +38,13 @@ Coin::Coin(const Vector& pos) : MovingSprite(pos, "images/objects/coin/coin.sprite", LAYER_TILES, COLGROUP_TOUCHABLE) { + sound_manager->preload("sounds/coin.wav"); } Coin::Coin(const lisp::Lisp& reader) : MovingSprite(reader, "images/objects/coin/coin.sprite", LAYER_TILES, COLGROUP_TOUCHABLE) { + sound_manager->preload("sounds/coin.wav"); } void @@ -50,7 +52,7 @@ Coin::collect() { // TODO: commented out musical code. Maybe fork this for a special "MusicalCoin" object? /* - static Timer sound_timer; + static Timer sound_timer; static int pitch_one = 128; static float last_pitch = 1; float pitch = 1; @@ -61,11 +63,11 @@ Coin::collect() pitch_one = tile; pitch = 1; last_pitch = 1; - } + } else if (sound_timer.get_timegone() < 0.02) { pitch = last_pitch; - } - else + } + else { switch ((pitch_one - tile) % 7) { case -6: @@ -115,7 +117,8 @@ Coin::collect() SoundSource* soundSource = sound_manager->create_sound_source("sounds/coin.wav"); soundSource->set_position(get_pos()); soundSource->set_pitch(pitch); - sound_manager->play_and_delete(soundSource); + soundSource->play(); + sound_manager->manage_source(soundSource); */ Sector::current()->player->get_status()->add_coins(1); Sector::current()->add_object(new BouncyCoin(get_pos()));