From 4ae0ca673042d6f1a55bd8ac67e1973efd598e3f Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Mon, 26 Apr 2004 10:46:45 +0000 Subject: [PATCH] - added bonus loading SVN-Revision: 732 --- src/world.cpp | 28 ++++++++++++++++++++++++++++ src/world.h | 4 ++++ src/worldmap.cpp | 4 ++++ 3 files changed, 36 insertions(+) diff --git a/src/world.cpp b/src/world.cpp index 6969e7a0c..e6d50fb25 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -52,6 +52,8 @@ World::World(const std::string& filename) activate_bad_guys(); activate_particle_systems(); get_level()->load_song(); + + apply_bonuses(); } World::World(const std::string& subset, int level_nr) @@ -69,6 +71,32 @@ World::World(const std::string& subset, int level_nr) activate_bad_guys(); activate_particle_systems(); get_level()->load_song(); + + apply_bonuses(); +} + +void +World::apply_bonuses() +{ + std::cout << "Bonus: " << player_status.bonus << std::endl; + + // Apply bonuses from former levels + switch (player_status.bonus) + { + case PlayerStatus::NO_BONUS: + break; + + case PlayerStatus::FLOWER_BONUS: + tux.got_coffee = true; + // fall through + + case PlayerStatus::GROWUP_BONUS: + // FIXME: Move this to Player class + tux.size = BIG; + tux.base.height = 64; + tux.base.y -= 32; + break; + } } World::~World() diff --git a/src/world.h b/src/world.h index b87a257d6..3399e03c8 100644 --- a/src/world.h +++ b/src/world.h @@ -111,6 +111,10 @@ public: /** Try to bumb a badguy that might we walking above Tux, thus shaking the tile which the badguy is walking on an killing him this way */ void trybumpbadguy(float x, float y); + + /** Apply bonuses active in the player status, used to reactivate + bonuses from former levels */ + void apply_bonuses(); }; /** FIMXE: Workaround for the leveleditor mainly */ diff --git a/src/worldmap.cpp b/src/worldmap.cpp index 50c0327db..c199abf2a 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -615,6 +615,7 @@ WorldMap::update() break; case GameSession::GAME_OVER: quit = true; + player_status.bonus = PlayerStatus::NO_BONUS; break; case GameSession::NONE: // Should never be reached @@ -863,12 +864,15 @@ WorldMap::loadgame(const std::string& filename) { Point p; std::string back_str = "none"; + std::string bonus_str = "none"; LispReader tux_reader(tux_cur); tux_reader.read_int("x", &p.x); tux_reader.read_int("y", &p.y); tux_reader.read_string("back", &back_str); + tux_reader.read_string("bonus", &bonus_str); + player_status.bonus = string_to_bonus(bonus_str); tux->back_direction = string_to_direction(back_str); tux->set_tile_pos(p); } -- 2.11.0