X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fplayer_status.cpp;h=09b9efa9e211fd9e1817b0d16b99bddd99728606;hb=fb8cef6efacc0dff5faaff6dc4aa638289285099;hp=41f5d75ae0f7d0c3dd7b9cf0990ec66b0e4e9de8;hpb=7c579d3ef0a6667c18b53dad84c63c05d2760a84;p=supertux.git diff --git a/src/player_status.cpp b/src/player_status.cpp index 41f5d75ae..09b9efa9e 100644 --- a/src/player_status.cpp +++ b/src/player_status.cpp @@ -19,7 +19,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include -#include +#include #include "lisp/writer.hpp" #include "lisp/lisp.hpp" #include "player_status.hpp" @@ -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; @@ -41,13 +42,13 @@ PlayerStatus::PlayerStatus() : coins(START_COINS), bonus(NO_BONUS), max_fire_bullets(0), - max_ice_bullets(0), - score_multiplier(1), - max_score_multiplier(1) + max_ice_bullets(0) { 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() @@ -58,19 +59,20 @@ void PlayerStatus::reset() { coins = START_COINS; bonus = NO_BONUS; - score_multiplier = 1; - max_score_multiplier = 1; } 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; + } } } @@ -98,7 +100,6 @@ PlayerStatus::write(lisp::Writer& writer) writer.write_int("iceflowers", max_ice_bullets); writer.write_int("coins", coins); - writer.write_int("max-score-multiplier", max_score_multiplier); } void @@ -125,7 +126,6 @@ PlayerStatus::read(const lisp::Lisp& lisp) lisp.get("iceflowers", max_ice_bullets); lisp.get("coins", coins); - lisp.get("max-score-multiplier", max_score_multiplier); } void @@ -153,9 +153,9 @@ PlayerStatus::draw(DrawingContext& context) Surface* coin_surf = coin_surface.get(); if (coin_surf) { - context.draw_surface(coin_surf, Vector(SCREEN_WIDTH - BORDER_X - coin_surf->get_width() - gold_fixed_text->get_text_width(coins_text), BORDER_Y + 1), LAYER_HUD); + context.draw_surface(coin_surf, Vector(SCREEN_WIDTH - BORDER_X - coin_surf->get_width() - fixed_font->get_text_width(coins_text), BORDER_Y + 1), LAYER_HUD); } - context.draw_text(gold_fixed_text, coins_text, Vector(SCREEN_WIDTH - BORDER_X, BORDER_Y), ALIGN_RIGHT, LAYER_HUD); + context.draw_text(fixed_font, coins_text, Vector(SCREEN_WIDTH - BORDER_X, BORDER_Y), ALIGN_RIGHT, LAYER_HUD, PlayerStatus::text_color); context.pop_transform(); } @@ -165,6 +165,4 @@ PlayerStatus::operator= (const PlayerStatus& other) { coins = other.coins; bonus = other.bonus; - score_multiplier = other.score_multiplier; - max_score_multiplier = other.max_score_multiplier; }