- fixed bug in live counting
authorIngo Ruhnke <grumbel@gmx.de>
Mon, 19 Apr 2004 13:23:33 +0000 (13:23 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Mon, 19 Apr 2004 13:23:33 +0000 (13:23 +0000)
- added save menu to the worldmap
- removed load/save from the game menu

SVN-Revision: 567

src/defines.h
src/gameloop.cpp
src/gameloop.h
src/setup.cpp
src/worldmap.cpp

index 6ea3cd7..2b053c3 100644 (file)
@@ -68,7 +68,7 @@ enum DyingType {
 #define MAX_RUN_XM 3.2
 #define MAX_YM 20.0
 #define MAX_JUMP_TIME 375
-#define MAX_LIVES 4.0
+#define MAX_LIVES 99
 
 #define WALK_SPEED 1.0
 #define RUN_SPEED 1.5
index 2dec06b..5e86022 100644 (file)
@@ -319,7 +319,8 @@ GameSession::check_end_conditions()
       // Check End conditions
       if (tux->is_dead())
         {
-          
+          player_status.lives -= 1;             
+    
           if (player_status.lives < 0)
             { // No more lives!?
               if(st_gl_mode != ST_GL_TEST)
@@ -327,8 +328,10 @@ GameSession::check_end_conditions()
           
               if(st_gl_mode != ST_GL_TEST)
                 {
-                  if (player_status.score > hs_score)
-                    save_hs(player_status.score);
+                  // FIXME: highscore soving doesn't make sense in its
+                  // current form
+                  //if (player_status.score > hs_score)
+                  //save_hs(player_status.score);
                 }
               
               exit_status = GAME_OVER;
@@ -436,14 +439,7 @@ GameSession::run()
                 case 2:
                   st_pause_ticks_stop();
                   break;
-                case 3:
-                  // FIXME:
-                  //update_load_save_game_menu(save_game_menu);
-                  break;
-                case 4:
-                  update_load_save_game_menu(load_game_menu);
-                  break;
-                case 7:
+                case 5:
                   st_pause_ticks_stop();
                   exit_status = LEVEL_ABORT;
                   break;
index d03a403..89c38e1 100644 (file)
@@ -51,9 +51,12 @@ class GameSession
   // FIXME: Hack for restarting the level
   std::string subset;
 
+ public:
   enum ExitStatus { NONE, LEVEL_FINISHED, GAME_OVER, LEVEL_ABORT };
+ private:
   ExitStatus exit_status;
  public:
+
   Timer time_left;
 
   GameSession(const std::string& subset, int levelnb, int mode);
index 4cfa59f..24397e8 100644 (file)
@@ -422,18 +422,17 @@ void st_menu(void)
   save_game_menu->additem(MN_HL,"",0,0);
   save_game_menu->additem(MN_BACK,"Back",0,0);
 
-  game_menu->additem(MN_LABEL,"InGame Menu",0,0);
+  game_menu->additem(MN_LABEL,"Pause",0,0);
   game_menu->additem(MN_HL,"",0,0);
-  game_menu->additem(MN_ACTION,"Return To Game",0,0);
-  game_menu->additem(MN_GOTO,"Save Game",0,save_game_menu);
-  game_menu->additem(MN_GOTO,"Load Game",0,load_game_menu);
+  game_menu->additem(MN_ACTION,"Continue",0,0);
   game_menu->additem(MN_GOTO,"Options",0,options_menu);
   game_menu->additem(MN_HL,"",0,0);
-  game_menu->additem(MN_ACTION,"Quit Game",0,0);
+  game_menu->additem(MN_ACTION,"Abort Level",0,0);
 
-  worldmap_menu->additem(MN_LABEL,"Worldmap Menu",0,0);
+  worldmap_menu->additem(MN_LABEL,"Pause",0,0);
   worldmap_menu->additem(MN_HL,"",0,0);
-  worldmap_menu->additem(MN_ACTION,"Return To Game",0,0);
+  worldmap_menu->additem(MN_ACTION,"Continue",0,0);
+  worldmap_menu->additem(MN_ACTION,"Save",0,0);
   worldmap_menu->additem(MN_GOTO,"Options",0,options_menu);
   worldmap_menu->additem(MN_HL,"",0,0);
   worldmap_menu->additem(MN_ACTION,"Quit Game",0,0);
@@ -463,7 +462,8 @@ bool process_load_game_menu()
 
       char slotfile[1024];
       snprintf(slotfile, 1024, "%s/slot%d.stsg", st_save_dir, slot-1);
-      
+     
+      // Load the game or at least set the savegame_file variable
       worldmap.loadgame(slotfile);
 
       worldmap.display();
index 85eb56e..a4be7e9 100644 (file)
@@ -499,19 +499,39 @@ WorldMap::update()
 {
   if (enter_level && !tux->is_moving())
     {
-      for(Levels::iterator i = levels.begin(); i != levels.end(); ++i)
+      Level* level = at_level();
+      if (level)
         {
-          if (i->x == tux->get_tile_pos().x && 
-              i->y == tux->get_tile_pos().y)
+          if (level->x == tux->get_tile_pos().x && 
+              level->y == tux->get_tile_pos().y)
             {
-              std::cout << "Enter the current level: " << i->name << std::endl;;
+              std::cout << "Enter the current level: " << level->name << std::endl;;
               halt_music();
-              GameSession session(datadir +  "levels/" + i->name,
+              
+              GameSession session(datadir +  "levels/" + level->name,
                                   1, ST_GL_LOAD_LEVEL_FILE);
-              session.run();
 
-              if (1) // FIXME: insert exit status checker here
-                i->solved = true;
+              switch (session.run())
+                {
+                case GameSession::LEVEL_FINISHED:
+                  level->solved = true;
+                  break;
+                case GameSession::LEVEL_ABORT:
+                  // Reseting the player_status might be a worthy
+                  // consideration, but I don't think we need it
+                  // 'cause only the bad players will use it to
+                  // 'cheat' a few items and that isn't necesarry a
+                  // bad thing (ie. better they continue that way,
+                  // then stop playing the game all together since it
+                  // is to hard)
+                  break;
+                case GameSession::GAME_OVER:
+                  quit = true;
+                  break;
+                case GameSession::NONE:
+                  // Should never be reached 
+                  break;
+                }
 
               play_music(song, 1);
               show_menu = 0;
@@ -521,8 +541,11 @@ WorldMap::update()
               return;
             }
         }
-      std::cout << "Nothing to enter at: "
-                << tux->get_tile_pos().x << ", " << tux->get_tile_pos().y << std::endl;
+      else
+        {
+          std::cout << "Nothing to enter at: "
+                    << tux->get_tile_pos().x << ", " << tux->get_tile_pos().y << std::endl;
+        }
     }
   else
     {
@@ -539,7 +562,12 @@ WorldMap::update()
             case 2: // Return to game
               menu_reset();
               break;
-            case 5: // Quit Worldmap
+            case 3:
+              if (!savegame_file.empty())
+                savegame(savegame_file);
+              break;
+                
+            case 6: // Quit Worldmap
               quit = true;
               break;
             }
@@ -674,6 +702,7 @@ WorldMap::display()
     SDL_Delay(20);
   }
 
+  halt_music();
   free_music(song);
 }
 
@@ -733,6 +762,9 @@ WorldMap::loadgame(const std::string& filename)
       reader.read_int("score",  &player_status.score);
       reader.read_int("distros", &player_status.distros);
 
+      if (player_status.lives < 0)
+        player_status.lives = 3;
+
       lisp_object_t* tux_cur = 0;
       if (reader.read_lisp("tux", &tux_cur))
         {
@@ -782,4 +814,7 @@ WorldMap::loadgame(const std::string& filename)
 
 } // namespace WorldMapNS
 
-/* EOF */
+/* Local Variables: */
+/* mode:c++ */
+/* End: */
+