From f51bc8fc15ac2a88eec6034a74f09e3b5bf65697 Mon Sep 17 00:00:00 2001 From: Christoph Sommer Date: Sat, 26 May 2007 14:34:05 +0000 Subject: [PATCH] Limit coin sound to be played at most once every 10ms SVN-Revision: 5020 --- src/player_status.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/player_status.cpp b/src/player_status.cpp index 352fac3d5..72111e6d4 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; @@ -65,12 +66,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; + } } } -- 2.11.0