- added saving of bonuses on worldmap, no loading yet
authorIngo Ruhnke <grumbel@gmx.de>
Mon, 26 Apr 2004 10:03:34 +0000 (10:03 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Mon, 26 Apr 2004 10:03:34 +0000 (10:03 +0000)
SVN-Revision: 731

src/gameloop.cpp
src/player.cpp
src/scene.cpp
src/scene.h
src/worldmap.cpp

index c12d9da..0243bfc 100644 (file)
@@ -599,9 +599,6 @@ GameSession::run()
         }
     }
   
-  delete world;
-  world = 0;
-
   return exit_status;
 }
 
index 77aaa1b..4e7779d 100644 (file)
@@ -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;                             
index fc29077..fccff6f 100644 (file)
@@ -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;
 
index 4038bd0..3b60112 100644 (file)
@@ -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;
index dbcc71a..50c0327 100644 (file)
@@ -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)