Removed vertical flipping drawing hacks.
[supertux.git] / src / world.cpp
index d8a4f7c..98b1ed5 100644 (file)
@@ -43,21 +43,26 @@ Surface* img_distro[4];
 World* World::current_ = 0;
 
 World::World(const std::string& filename, int level_nr)
+  : level(0), tux(0), background(0), camera(0)
 {
   // FIXME: Move this to action and draw and everywhere else where the
   // world calls child functions
   current_ = this;
 
+  tux = new Player(displaymanager);
+  add_object(tux);
+  
   level = new Level();
+  camera = new Camera(tux, level);
+  add_object(camera);                 
+
   if(level_nr >= 0) {
     level->load(filename, level_nr, this);
   } else {
     level->load(filename, this);
   }
-
-  tux = new Player(displaymanager);
-  add_object(tux);
-
+  tux->move(level->start_pos);
+  
   set_defaults();
 
   level->load_gfx();
@@ -75,9 +80,6 @@ World::World(const std::string& filename, int level_nr)
   add_object(new TileMap(displaymanager, level));
   level->load_song();
 
-  camera = new Camera(tux, level);
-  add_object(camera);               
-
   apply_bonuses();
 }
 
@@ -95,7 +97,7 @@ World::apply_bonuses()
       // fall through
                                                                                 
     case PlayerStatus::GROWUP_BONUS:
-      tux->grow();
+      tux->grow(false);
       break;
     }
 }
@@ -108,6 +110,8 @@ World::~World()
   }
 
   delete level;
+
+  current_ = 0;
 }
 
 void
@@ -196,14 +200,14 @@ World::draw()
 void
 World::action(float elapsed_time)
 {
-  tux->check_bounds(*camera,
-      level->back_scrolling, (bool)level->hor_autoscroll_speed);
+  tux->check_bounds(*camera);
     
   /* update objects (don't use iterators here, because the list might change
    * during the iteration)
    */
   for(size_t i = 0; i < gameobjects.size(); ++i)
-    gameobjects[i]->action(elapsed_time);
+    if(gameobjects[i]->is_valid())
+      gameobjects[i]->action(elapsed_time);
 
   /* Handle all possible collisions. */
   collision_handler();