From: Ingo Ruhnke Date: Tue, 20 Apr 2004 20:10:53 +0000 (+0000) Subject: - added stay-on-platform into the level fileformat X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=ee6db785e8eff4883da70b404a9bdb4a42e75ac3;p=supertux.git - added stay-on-platform into the level fileformat SVN-Revision: 603 --- diff --git a/src/badguy.cpp b/src/badguy.cpp index 82fe54d09..2d1de29d9 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -144,7 +144,7 @@ std::string badguykind_to_string(BadGuyKind kind) } void -BadGuy::init(float x, float y, BadGuyKind kind_) +BadGuy::init(float x, float y, BadGuyKind kind_, bool stay_on_platform_) { base.x = x; base.y = y; @@ -153,7 +153,7 @@ BadGuy::init(float x, float y, BadGuyKind kind_) base.xm = 0; base.ym = 0; - stay_on_platform = false; + stay_on_platform = stay_on_platform_; mode = NORMAL; dying = DYING_NOT; kind = kind_; diff --git a/src/badguy.h b/src/badguy.h index 7ec03e325..8ea7f2e65 100644 --- a/src/badguy.h +++ b/src/badguy.h @@ -124,7 +124,7 @@ private: float animation_speed; public: - void init(float x, float y, BadGuyKind kind); + void init(float x, float y, BadGuyKind kind, bool stay_on_platform); void action(float frame_ratio); void draw(); diff --git a/src/level.cpp b/src/level.cpp index 7e6e1820b..9ae1831ee 100644 --- a/src/level.cpp +++ b/src/level.cpp @@ -358,6 +358,7 @@ Level::load(const std::string& filename) LispReader reader(lisp_cdr(data)); reader.read_int("x", &bg_data.x); reader.read_int("y", &bg_data.y); + reader.read_bool("stay-on-platform", &bg_data.stay_on_platform); badguy_data.push_back(bg_data); @@ -572,7 +573,9 @@ Level::save(const char * subset, int level) for(std::vector::iterator it = badguy_data.begin(); it != badguy_data.end(); ++it) - fprintf( fi,"(%s (x %d) (y %d))\n",badguykind_to_string((*it).kind).c_str(),(*it).x,(*it).y); + fprintf( fi,"(%s (x %d) (y %d) (stay-on-platform %s))\n", + badguykind_to_string((*it).kind).c_str(),(*it).x,(*it).y, + it->stay_on_platform ? "#t" : "#f"); fprintf( fi,")\n"); diff --git a/src/leveleditor.cpp b/src/leveleditor.cpp index f20ff31c5..6933e39e1 100644 --- a/src/leveleditor.cpp +++ b/src/leveleditor.cpp @@ -95,7 +95,7 @@ struct LevelEditorWorld bad_guys.push_back(BadGuy()); BadGuy& new_bad_guy = bad_guys.back(); - new_bad_guy.init(x,y,kind); + new_bad_guy.init(x,y,kind, false /* stay_on_platform */); } void activate_bad_guys() diff --git a/src/world.cpp b/src/world.cpp index b0a46734f..f43d3e1ca 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -97,7 +97,7 @@ World::activate_bad_guys() i != level->badguy_data.end(); ++i) { - add_bad_guy(i->x, i->y, i->kind); + add_bad_guy(i->x, i->y, i->kind, i->stay_on_platform); } } @@ -380,12 +380,12 @@ World::add_bouncy_brick(float x, float y) } void -World::add_bad_guy(float x, float y, BadGuyKind kind) +World::add_bad_guy(float x, float y, BadGuyKind kind, bool stay_on_platform) { bad_guys.push_back(BadGuy()); BadGuy& new_bad_guy = bad_guys.back(); - new_bad_guy.init(x,y,kind); + new_bad_guy.init(x,y,kind, stay_on_platform); } void diff --git a/src/world.h b/src/world.h index 00ea9a056..ea2761023 100644 --- a/src/world.h +++ b/src/world.h @@ -86,7 +86,7 @@ class World void add_broken_brick(Tile* tile, float x, float y); void add_broken_brick_piece(Tile* tile, float x, float y, float xm, float ym); void add_bouncy_brick(float x, float y); - void add_bad_guy(float x, float y, BadGuyKind kind); + void add_bad_guy(float x, float y, BadGuyKind kind, bool stay_on_platform = false); void add_upgrade(float x, float y, Direction dir, UpgradeKind kind); void add_bullet(float x, float y, float xm, Direction dir);