X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fsector.cpp;h=4cde141967339ab83157baebf95a6242dc6c90f2;hb=546364c9567ef212ea9276201facf73f5ada696a;hp=52167756f7838906d4bf3aa20265950c744ff72b;hpb=ca3b6dabb3a339a05b33ed0b90001b6d712b28da;p=supertux.git diff --git a/src/sector.cpp b/src/sector.cpp index 52167756f..4cde14196 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -45,8 +45,9 @@ Sector* Sector::_current = 0; Sector::Sector() - : gravity(10), player(0), solids(0), background(0), camera(0), - end_sequence_animation_type(NONE_ENDSEQ_ANIM), currentmusic(LEVEL_MUSIC) + : end_sequence_animation_type(NONE_ENDSEQ_ANIM), + gravity(10), player(0), solids(0), background(0), camera(0), + currentmusic(LEVEL_MUSIC) { song_title = "Mortimers_chipdisko.mod"; player = new Player(); @@ -67,6 +68,23 @@ Sector::~Sector() _current = 0; } +Sector *Sector::create(const std::string& name, size_t width, size_t height) +{ + Sector *sector = new Sector; + sector->name = name; + TileMap *background = new TileMap(LAYER_BACKGROUNDTILES, false, width, height); + TileMap *interactive = new TileMap(LAYER_TILES, true, width, height); + TileMap *foreground = new TileMap(LAYER_FOREGROUNDTILES, false, width, height); + sector->add_object(background); + sector->add_object(interactive); + sector->add_object(foreground); + sector->solids = interactive; + sector->camera = new Camera(sector); + sector->add_object(sector->camera); + sector->update_game_objects(); + return sector; +} + void Sector::parse(LispReader& lispreader) { @@ -700,10 +718,12 @@ Sector::add_bouncy_brick(const Vector& pos) } BadGuy* -Sector::add_bad_guy(float x, float y, BadGuyKind kind) +Sector::add_bad_guy(float x, float y, BadGuyKind kind, bool activate) { BadGuy* badguy = new BadGuy(kind, x, y); add_object(badguy); + if(activate) + badguy->activate(LEFT); return badguy; } @@ -749,12 +769,18 @@ Sector::add_smoke_cloud(const Vector& pos) } bool -Sector::add_particles(const Vector& epicenter, const Vector& velocity, const Vector& acceleration, int number, Color color, int size, int life_time) +Sector::add_particles(const Vector& epicenter, int min_angle, int max_angle, const Vector& initial_velocity, const Vector& acceleration, int number, Color color, int size, int life_time, int drawing_layer) { - add_object(new Particles(epicenter, velocity, acceleration, number, color, size, life_time)); + add_object(new Particles(epicenter, min_angle, max_angle, initial_velocity, acceleration, number, color, size, life_time, drawing_layer)); return true; } +void +Sector::add_floating_text(const Vector& pos, const std::string& text) +{ + add_object(new FloatingText(pos, text)); +} + /* Break a brick: */ bool Sector::trybreakbrick(const Vector& pos, bool small)