yeti cleanup and death animation rework, hitbox fix ups
[supertux.git] / src / mainloop.cpp
index afd60ae..523db81 100644 (file)
@@ -1,5 +1,5 @@
-//  $Id: worldmap.hpp 2800 2005-10-02 22:57:31Z matzebraun $
-// 
+//  $Id$
+//
 //  SuperTux
 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
 //
@@ -12,7 +12,7 @@
 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 //  GNU General Public License for more details.
-// 
+//
 //  You should have received a copy of the GNU General Public License
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -26,7 +26,6 @@
 #include "control/joystickkeyboardcontroller.hpp"
 #include "gui/menu.hpp"
 #include "audio/sound_manager.hpp"
-#include "script_manager.hpp"
 #include "gameconfig.hpp"
 #include "main.hpp"
 #include "resources.hpp"
@@ -44,7 +43,6 @@ MainLoop* main_loop = NULL;
 MainLoop::MainLoop()
   : speed(1.0)
 {
-  console.reset(new Console());
 }
 
 MainLoop::~MainLoop()
@@ -66,6 +64,10 @@ MainLoop::push_screen(Screen* screen)
 void
 MainLoop::exit_screen()
 {
+  if (screen_stack.size() < 1) {
+    quit();
+    return;
+  }
   next_screen.reset(screen_stack.back());
   nextpush = false;
   screen_stack.pop_back();
@@ -105,7 +107,7 @@ MainLoop::run()
       }
       
       next_screen->setup();
-      script_manager->fire_wakeup_event(ScriptManager::SCREEN_SWITCHED);
+      ScriptManager::instance->fire_wakeup_event(ScriptManager::SCREEN_SWITCHED);
       current_screen.reset(next_screen.release());
       next_screen.reset(NULL);
       nextpush = false;
@@ -143,7 +145,7 @@ MainLoop::run()
       current_screen->draw(context);
       if(Menu::current() != NULL)
           Menu::current()->draw(context);
-      console->draw(context);
+      Console::instance->draw(context);
 
       context.do_drawing();
 
@@ -164,8 +166,9 @@ MainLoop::run()
     elapsed_time *= speed;
 
     game_time += elapsed_time;
-    script_manager->update();
+    ScriptManager::instance->update();
     current_screen->update(elapsed_time);
+    Console::instance->update(elapsed_time);
  
     main_controller->update();
     SDL_Event event;