X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fsupertux%2Fplayer_status.cpp;h=2c95b8f9334799a98589e7bfacb0cbea16a6ef06;hb=394aff4351bc13e8118482621926e95328fbea71;hp=6980414cedb7d6f268dea18de7c505cf0bbcdea2;hpb=a68b712c0a7cf99e08a63ea9aa7f927cfb132562;p=supertux.git diff --git a/src/supertux/player_status.cpp b/src/supertux/player_status.cpp index 6980414ce..2c95b8f93 100644 --- a/src/supertux/player_status.cpp +++ b/src/supertux/player_status.cpp @@ -40,6 +40,8 @@ PlayerStatus::PlayerStatus() : bonus(NO_BONUS), max_fire_bullets(0), max_ice_bullets(0), + max_air_time(0), + max_earth_time(0), displayed_coins(DISPLAYED_COINS_UNSET), displayed_coins_frame(0), coin_surface() @@ -47,8 +49,8 @@ PlayerStatus::PlayerStatus() : reset(); coin_surface = Surface::create("images/engine/hud/coins-0.png"); - sound_manager->preload("sounds/coin.wav"); - sound_manager->preload("sounds/lifeup.wav"); + SoundManager::current()->preload("sounds/coin.wav"); + SoundManager::current()->preload("sounds/lifeup.wav"); } PlayerStatus::~PlayerStatus() @@ -65,15 +67,17 @@ 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 if (real_time > sound_played_time + 0.010) { - sound_manager->play("sounds/coin.wav"); - sound_played_time = real_time; - } + + if(!play_sound) + return; + + static float sound_played_time = 0; + if(count >= 100) + SoundManager::current()->play("sounds/lifeup.wav"); + else if (real_time > sound_played_time + 0.010) { + SoundManager::current()->play("sounds/coin.wav"); + sound_played_time = real_time; } } @@ -93,12 +97,20 @@ PlayerStatus::write(lisp::Writer& writer) case ICE_BONUS: writer.write("bonus", "iceflower"); break; + case AIR_BONUS: + writer.write("bonus", "airflower"); + break; + case EARTH_BONUS: + writer.write("bonus", "earthflower"); + break; default: log_warning << "Unknown bonus type." << std::endl; writer.write("bonus", "none"); } writer.write("fireflowers", max_fire_bullets); writer.write("iceflowers", max_ice_bullets); + writer.write("airflowers", max_air_time); + writer.write("earthflowers", max_earth_time); writer.write("coins", coins); } @@ -118,6 +130,10 @@ PlayerStatus::read(const Reader& lisp) bonus = FIRE_BONUS; } else if(bonusname == "iceflower") { bonus = ICE_BONUS; + } else if(bonusname == "airflower") { + bonus = AIR_BONUS; + } else if(bonusname == "earthflower") { + bonus = EARTH_BONUS; } else { log_warning << "Unknown bonus '" << bonusname << "' in savefile" << std::endl; bonus = NO_BONUS; @@ -125,6 +141,8 @@ PlayerStatus::read(const Reader& lisp) } lisp.get("fireflowers", max_fire_bullets); lisp.get("iceflowers", max_ice_bullets); + lisp.get("airflowers", max_air_time); + lisp.get("earthflowers", max_earth_time); lisp.get("coins", coins); } @@ -155,13 +173,13 @@ PlayerStatus::draw(DrawingContext& context) if (coin_surface) { - context.draw_surface(coin_surface, - Vector(SCREEN_WIDTH - BORDER_X - coin_surface->get_width() - Resources::fixed_font->get_text_width(coins_text), + context.draw_surface(coin_surface, + Vector(SCREEN_WIDTH - BORDER_X - coin_surface->get_width() - Resources::fixed_font->get_text_width(coins_text), BORDER_Y + 1 + (Resources::fixed_font->get_text_height(coins_text) + 5) * player_id), LAYER_HUD); } - context.draw_text(Resources::fixed_font, - coins_text, + context.draw_text(Resources::fixed_font, + coins_text, Vector(SCREEN_WIDTH - BORDER_X - Resources::fixed_font->get_text_width(coins_text), BORDER_Y + (Resources::fixed_font->get_text_height(coins_text) + 5) * player_id), ALIGN_LEFT,