X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fobject%2Fcoin.cpp;h=c75312fb9adfb02633fcde87821be07c16202a41;hb=08ccb17345a52f5ffd8a5dd6ecf675cad55f16a7;hp=2684bcd2a0e816342d3a4dc9817d7110a1a1e8cb;hpb=b4868c421ba670cd6301394558f1034e38a0c7b3;p=supertux.git diff --git a/src/object/coin.cpp b/src/object/coin.cpp index 2684bcd2a..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: