lazily load tile images to speedup startup times
[supertux.git] / src / gameloop.cpp
index a5933de..3267063 100644 (file)
@@ -80,10 +80,10 @@ bool compare_last(std::string& haystack, std::string needle)
 }
 
 GameSession::GameSession(const std::string& levelfile_, int mode,
-    bool flip_level_, Statistics* statistics)
+    Statistics* statistics)
   : level(0), currentsector(0), st_gl_mode(mode),
     end_sequence(NO_ENDSEQUENCE), levelfile(levelfile_),
-    flip_level(flip_level_), best_level_statistics(statistics)
+    best_level_statistics(statistics)
 {
   current_ = this;
   
@@ -92,9 +92,6 @@ GameSession::GameSession(const std::string& levelfile_, int mode,
 
   context = new DrawingContext();
 
-  if(flip_levels_mode)
-    flip_level = true;
-
   last_swap_point = Vector(-1, -1);
   last_swap_stats.reset();
 
@@ -124,8 +121,6 @@ GameSession::restart_level()
 
   level = new Level;
   level->load(levelfile);
-  if(flip_level)
-    level->do_vertical_flip();
 
   global_stats.reset();
   global_stats.set_total_points(COINS_COLLECTED_STAT, level->get_total_coins());
@@ -185,8 +180,13 @@ GameSession::levelintro(void)
   char str[60];
 
   DrawingContext context;
-  if(currentsector->background)
-    currentsector->background->draw(context);
+  for(Sector::GameObjects::iterator i = currentsector->gameobjects.begin();
+      i != currentsector->gameobjects.end(); ++i) {
+    Background* background = dynamic_cast<Background*> (*i);
+    if(background) {
+      background->draw(context);
+    }
+  }
 
 //  context.draw_text(gold_text, level->get_name(), Vector(screen->w/2, 160),
 //      CENTER_ALLIGN, LAYER_FOREGROUND1);
@@ -204,11 +204,6 @@ GameSession::levelintro(void)
       Vector(screen->w/2, 350), CENTER_ALLIGN, LAYER_FOREGROUND1);
 
 
-  if(flip_level)
-    context.draw_text(white_text,
-      _("Level Vertically Flipped!"),
-      Vector(screen->w/2, 310), CENTER_ALLIGN, LAYER_FOREGROUND1);
-
   if(best_level_statistics != NULL)
     best_level_statistics->draw_message_info(context, _("Best Level Statistics"));
 
@@ -905,12 +900,18 @@ GameSession::drawstatus(DrawingContext& context)
 }
 
 void
-GameSession::drawresultscreen(void)
+GameSession::drawresultscreen()
 {
   char str[80];
 
   DrawingContext context;
-  currentsector->background->draw(context);  
+  for(Sector::GameObjects::iterator i = currentsector->gameobjects.begin();
+      i != currentsector->gameobjects.end(); ++i) {
+    Background* background = dynamic_cast<Background*> (*i);
+    if(background) {
+      background->draw(context);
+    }
+  }
 
   context.draw_text(blue_text, _("Result:"), Vector(screen->w/2, 200),
       CENTER_ALLIGN, LAYER_FOREGROUND1);