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();
add_object(new TileMap(displaymanager, level));
level->load_song();
- camera = new Camera(tux, level);
- add_object(camera);
-
apply_bonuses();
}
// fall through
case PlayerStatus::GROWUP_BONUS:
- tux->grow();
+ tux->grow(false);
break;
}
}
}
delete level;
+
+ current_ = 0;
}
void
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)