X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fplayer_status.cpp;h=24a1b992e614a50075c647f8f715ef361497ba53;hb=2bfc38ef3208dee885452cfa59a7c7df671eb24d;hp=02a44e9d9333bfca1cdfcd4a1b09cb5405d7c6b2;hpb=eb6819ec3002b546e67401f7600cc93e0ec32daf;p=supertux.git diff --git a/src/player_status.cpp b/src/player_status.cpp index 02a44e9d9..24a1b992e 100644 --- a/src/player_status.cpp +++ b/src/player_status.cpp @@ -1,7 +1,8 @@ // $Id$ // -// SuperTux - A Jump'n Run +// SuperTux // Copyright (C) 2003 Tobias Glaesser +// Copyright (C) 2006 Matthias Braun // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -28,7 +29,7 @@ #include "sprite/sprite_manager.hpp" #include "math/vector.hpp" #include "main.hpp" -#include "msg.hpp" +#include "log.hpp" static const int START_COINS = 100; static const int MAX_COINS = 99999; @@ -38,6 +39,8 @@ PlayerStatus* player_status = 0; PlayerStatus::PlayerStatus() : coins(START_COINS), bonus(NO_BONUS), + max_fire_bullets(0), + max_ice_bullets(0), score_multiplier(1), max_score_multiplier(1) { @@ -55,7 +58,7 @@ PlayerStatus::PlayerStatus() tux_life.reset(sprite_manager->create("images/creatures/tux_small/tux-life.sprite")); - Console::registerCommand("coins", this); + Console::instance->registerCommand("coins", this); } PlayerStatus::~PlayerStatus() @@ -72,17 +75,13 @@ void PlayerStatus::reset() } void -PlayerStatus::incLives() +PlayerStatus::add_coins(int count) { - player_status->coins = std::min(player_status->coins+100, MAX_COINS); - sound_manager->play("sounds/lifeup.wav"); -} - -void -PlayerStatus::incCoins() -{ - coins++; - sound_manager->play("sounds/coin.wav"); + coins = std::min(coins + count, MAX_COINS); + if(count >= 100) + sound_manager->play("sounds/lifeup.wav"); + else + sound_manager->play("sounds/coin.wav"); } void @@ -113,9 +112,12 @@ PlayerStatus::write(lisp::Writer& writer) writer.write_string("bonus", "iceflower"); break; default: - msg_warning << "Unknown bonus type." << std::endl; + log_warning << "Unknown bonus type." << std::endl; writer.write_string("bonus", "none"); } + writer.write_int("fireflowers", max_fire_bullets); + writer.write_int("iceflowers", max_ice_bullets); + writer.write_bool("key-brass", keys & KEY_BRASS); writer.write_bool("key-iron", keys & KEY_IRON); writer.write_bool("key-bronze", keys & KEY_BRONZE); @@ -142,10 +144,13 @@ PlayerStatus::read(const lisp::Lisp& lisp) } else if(bonusname == "iceflower") { bonus = ICE_BONUS; } else { - msg_warning << "Unknown bonus '" << bonusname << "' in savefile" << std::endl; + log_warning << "Unknown bonus '" << bonusname << "' in savefile" << std::endl; bonus = NO_BONUS; } } + lisp.get("fireflowers", max_fire_bullets); + lisp.get("iceflowers", max_ice_bullets); + bool val = false; if(lisp.get("key-brass", val) && val == true) set_keys(KEY_BRASS); @@ -194,7 +199,7 @@ PlayerStatus::draw(DrawingContext& context) context.draw_text(white_text, coinstext, Vector(SCREEN_WIDTH - white_text->get_text_width(coinstext) - gold_text->get_text_width(" 99999") - BORDER_X, BORDER_Y), LEFT_ALLIGN, LAYER_FOREGROUND1); context.draw_text(gold_text, str, Vector(SCREEN_WIDTH - BORDER_X, BORDER_Y), RIGHT_ALLIGN, LAYER_FOREGROUND1); - draw_keys(context); + //draw_keys(context); context.pop_transform(); } @@ -214,7 +219,7 @@ PlayerStatus::consoleCommand(std::string command, std::vector argum { if (command == "coins") { if ((arguments.size() < 1) || (!Console::string_is(arguments[0]))) { - msg_info << "Usage: coins " << std::endl; + log_info << "Usage: coins " << std::endl; } else { coins = Console::string_to(arguments[0]); }