From ba3fe78c10fc424195eba230fa0820bf90c7b2f3 Mon Sep 17 00:00:00 2001 From: florianf Date: Sat, 30 Jan 2010 10:21:26 +0000 Subject: [PATCH] Bug 508: Make PlayerStatus::reset reset displayed_coins. Resolves #508. Thanks to Matt McCutchen for this patch. git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6288 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- src/supertux/player_status.cpp | 16 +++++++++++----- src/supertux/player_status.hpp | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/supertux/player_status.cpp b/src/supertux/player_status.cpp index eef573cd7..b1e5090f8 100644 --- a/src/supertux/player_status.cpp +++ b/src/supertux/player_status.cpp @@ -30,13 +30,18 @@ static const int START_COINS = 100; static const int MAX_COINS = 9999; +static const int DISPLAYED_COINS_UNSET = -1; + PlayerStatus* player_status = 0; PlayerStatus::PlayerStatus() : + /* Do we really want -Weffc++ to bully us into duplicating code from "reset" here? */ coins(START_COINS), bonus(NO_BONUS), max_fire_bullets(0), max_ice_bullets(0), + displayed_coins(DISPLAYED_COINS_UNSET), + displayed_coins_frame(0), coin_surface() { reset(); @@ -54,6 +59,7 @@ void PlayerStatus::reset() { coins = START_COINS; bonus = NO_BONUS; + displayed_coins = DISPLAYED_COINS_UNSET; } void @@ -126,14 +132,14 @@ PlayerStatus::read(const Reader& lisp) void PlayerStatus::draw(DrawingContext& context) { - static int displayed_coins = -1; - static int next_count = 0; - if ((displayed_coins == -1) || (fabsf(displayed_coins - coins) > 100)) { + if ((displayed_coins == DISPLAYED_COINS_UNSET) || + (fabsf(displayed_coins - coins) > 100)) { displayed_coins = coins; + displayed_coins_frame = 0; } - if (++next_count > 2) { - next_count = 0; + if (++displayed_coins_frame > 2) { + displayed_coins_frame = 0; if (displayed_coins < coins) displayed_coins++; if (displayed_coins > coins) displayed_coins--; } diff --git a/src/supertux/player_status.hpp b/src/supertux/player_status.hpp index 7b320de75..2ad2836fe 100644 --- a/src/supertux/player_status.hpp +++ b/src/supertux/player_status.hpp @@ -58,6 +58,8 @@ public: int max_ice_bullets; /**< maximum number of ice bullets in play */ private: + int displayed_coins; + int displayed_coins_frame; SurfacePtr coin_surface; private: -- 2.11.0