From 6e7c9ecb1777113d2cd38ba3846acba6b249fd62 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Mon, 26 Apr 2004 10:03:34 +0000 Subject: [PATCH] - added saving of bonuses on worldmap, no loading yet SVN-Revision: 731 --- src/gameloop.cpp | 3 --- src/player.cpp | 2 +- src/scene.cpp | 28 +++++++++++++++++++++++++++- src/scene.h | 5 +++++ src/worldmap.cpp | 11 +++++++++-- 5 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/gameloop.cpp b/src/gameloop.cpp index c12d9da2a..0243bfc35 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -599,9 +599,6 @@ GameSession::run() } } - delete world; - world = 0; - return exit_status; } diff --git a/src/player.cpp b/src/player.cpp index 77aaa1bae..4e7779df6 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -440,7 +440,7 @@ Player::handle_input() } /* Duck! */ - if (input.down == DOWN && size == BIG && !duck && physic.get_velocity_y() == 0) + if (input.down == DOWN && size == BIG && !duck && physic.get_velocity_y() == 0 && on_ground()) { duck = true; base.height = 32; diff --git a/src/scene.cpp b/src/scene.cpp index fc290771e..fccff6f41 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -27,10 +27,36 @@ PlayerStatus::PlayerStatus() : score(0), distros(0), lives(START_LIVES), - score_multiplier(1) + score_multiplier(1), + bonus(NO_BONUS) { } +std::string bonus_to_string(PlayerStatus::BonusType b) +{ + switch (b) + { + case PlayerStatus::NO_BONUS: + return "none"; + case PlayerStatus::GROWUP_BONUS: + return "growup"; + case PlayerStatus::FLOWER_BONUS: + return "icflower"; + } +} + +PlayerStatus::BonusType string_to_bonus(const std::string& str) +{ + if (str == "none") + return PlayerStatus::NO_BONUS; + else if (str == "growup") + return PlayerStatus::GROWUP_BONUS; + else if (str == "iceflower") + return PlayerStatus::FLOWER_BONUS; + else + return PlayerStatus::NO_BONUS; +} + // FIXME: Move this into a view class float scroll_x; diff --git a/src/scene.h b/src/scene.h index 4038bd023..3b60112a6 100644 --- a/src/scene.h +++ b/src/scene.h @@ -31,12 +31,17 @@ struct PlayerStatus int score; int distros; int lives; + enum BonusType { NO_BONUS, GROWUP_BONUS, FLOWER_BONUS }; + BonusType bonus; int score_multiplier; PlayerStatus(); }; +std::string bonus_to_string(PlayerStatus::BonusType b); +PlayerStatus::BonusType string_to_bonus(const std::string& str); + extern PlayerStatus player_status; extern float scroll_x; diff --git a/src/worldmap.cpp b/src/worldmap.cpp index dbcc71aa0..50c0327db 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -597,6 +597,12 @@ WorldMap::update() { case GameSession::LEVEL_FINISHED: level->solved = true; + if (session.get_world()->get_tux()->got_coffee) + player_status.bonus = PlayerStatus::FLOWER_BONUS; + else if (session.get_world()->get_tux()->size == BIG) + player_status.bonus = PlayerStatus::GROWUP_BONUS; + else + player_status.bonus = PlayerStatus::NO_BONUS; break; case GameSession::LEVEL_ABORT: // Reseting the player_status might be a worthy @@ -809,8 +815,9 @@ WorldMap::savegame(const std::string& filename) << " (lives " << player_status.lives << ")\n" << " (score " << player_status.score << ")\n" << " (distros " << player_status.distros << ")\n" - << " (tux (x " << tux->get_tile_pos().x << ") (y " << tux->get_tile_pos().y << ")" - << " (back \"" << direction_to_string(tux->back_direction) << "\"))\n" + << " (tux (x " << tux->get_tile_pos().x << ") (y " << tux->get_tile_pos().y << ")\n" + << " (back \"" << direction_to_string(tux->back_direction) << "\")\n" + << " (bonus \"" << bonus_to_string(player_status.bonus) << "\"))\n" << " (levels\n"; for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) -- 2.11.0