X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fplayer_status.cpp;h=4bed7dfcb74b7aacc3bbb16bfbd775f1eced4d09;hb=7819b316c47ea1304251f70cc2971400847a8d96;hp=352fac3d5fcce373b2ac52f96aae690d1038c026;hpb=f955a4262c3924e14c97025f463252e7f1ca7a03;p=supertux.git diff --git a/src/player_status.cpp b/src/player_status.cpp index 352fac3d5..4bed7dfcb 100644 --- a/src/player_status.cpp +++ b/src/player_status.cpp @@ -31,6 +31,7 @@ #include "math/vector.hpp" #include "main.hpp" #include "log.hpp" +#include "timer.hpp" static const int START_COINS = 100; static const int MAX_COINS = 99999; @@ -48,6 +49,8 @@ PlayerStatus::PlayerStatus() reset(); coin_surface.reset(new Surface("images/engine/hud/coins-0.png")); + sound_manager->preload("sounds/coin.wav"); + sound_manager->preload("sounds/lifeup.wav"); } PlayerStatus::~PlayerStatus() @@ -65,12 +68,15 @@ void PlayerStatus::reset() void PlayerStatus::add_coins(int count, bool play_sound) { + static float sound_played_time = 0; coins = std::min(coins + count, MAX_COINS); if(play_sound) { if(count >= 100) sound_manager->play("sounds/lifeup.wav"); - else + else if (real_time > sound_played_time + 0.010) { sound_manager->play("sounds/coin.wav"); + sound_played_time = real_time; + } } }