From 2eb182673565083de4184a4168ef823a97c73e48 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Wed, 28 Apr 2004 20:24:34 +0000 Subject: [PATCH] MatzeB: that shoudl fix the cases where you die when picking up an iceflower SVN-Revision: 817 --- src/gameobjs.cpp | 13 +++++++++++-- src/special.cpp | 6 ------ src/world.cpp | 32 ++++++++++++++++---------------- src/world.h | 8 ++++---- 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/gameobjs.cpp b/src/gameobjs.cpp index 5133535af..aaf6319f2 100644 --- a/src/gameobjs.cpp +++ b/src/gameobjs.cpp @@ -40,7 +40,14 @@ BouncyDistro::action(double frame_ratio) base.ym += 0.1 * frame_ratio; if (base.ym >= 0) - World::current()->bouncy_distros.erase(static_cast::iterator>(this)); + { + std::vector::iterator i + = std::find(World::current()->bouncy_distros.begin(), + World::current()->bouncy_distros.end(), + this); + if (i != World::current()->bouncy_distros.end()) + World::current()->bouncy_distros.erase(i); + } } void @@ -71,7 +78,9 @@ BrokenBrick::action(double frame_ratio) base.y = base.y + base.ym * frame_ratio; if (!timer.check()) - World::current()->broken_bricks.erase(static_cast::iterator>(this)); + { + World::current()->broken_bricks.erase(static_cast::iterator>(this)); + } } void diff --git a/src/special.cpp b/src/special.cpp index b2874769a..b1136c7bd 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -350,12 +350,6 @@ Upgrade::collision(void* p_c_object, int c_object, CollisionType type) pplayer->base.height = 64; pplayer->base.y -= 32; } - if(collision_object_map(pplayer->base)) - { - pplayer->base.height = 32; - pplayer->base.y += 32; - pplayer->duck = true; - } } else if (kind == UPGRADE_HERRING) { diff --git a/src/world.cpp b/src/world.cpp index fb9d49b74..7ec7eacdf 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -198,7 +198,7 @@ World::draw() /* (Bouncy bricks): */ for (unsigned int i = 0; i < bouncy_bricks.size(); ++i) - bouncy_bricks[i].draw(); + bouncy_bricks[i]->draw(); for (BadGuys::iterator i = bad_guys.begin(); i != bad_guys.end(); ++i) (*i)->draw(); @@ -209,16 +209,16 @@ World::draw() bullets[i].draw(); for (unsigned int i = 0; i < floating_scores.size(); ++i) - floating_scores[i].draw(); + floating_scores[i]->draw(); for (unsigned int i = 0; i < upgrades.size(); ++i) upgrades[i].draw(); for (unsigned int i = 0; i < bouncy_distros.size(); ++i) - bouncy_distros[i].draw(); + bouncy_distros[i]->draw(); for (unsigned int i = 0; i < broken_bricks.size(); ++i) - broken_bricks[i].draw(); + broken_bricks[i]->draw(); /* Draw foreground: */ for (y = 0; y < 15; ++y) @@ -244,11 +244,11 @@ World::action(double frame_ratio) /* Handle bouncy distros: */ for (unsigned int i = 0; i < bouncy_distros.size(); i++) - bouncy_distros[i].action(frame_ratio); + bouncy_distros[i]->action(frame_ratio); /* Handle broken bricks: */ for (unsigned int i = 0; i < broken_bricks.size(); i++) - broken_bricks[i].action(frame_ratio); + broken_bricks[i]->action(frame_ratio); /* Handle distro counting: */ if (counting_distros) @@ -261,10 +261,10 @@ World::action(double frame_ratio) // Handle all kinds of game objects for (unsigned int i = 0; i < bouncy_bricks.size(); i++) - bouncy_bricks[i].action(frame_ratio); + bouncy_bricks[i]->action(frame_ratio); for (unsigned int i = 0; i < floating_scores.size(); i++) - floating_scores[i].action(frame_ratio); + floating_scores[i]->action(frame_ratio); for (unsigned int i = 0; i < bullets.size(); ++i) bullets[i].action(frame_ratio); @@ -387,16 +387,16 @@ World::add_score(float x, float y, int s) { player_status.score += s; - FloatingScore new_floating_score; - new_floating_score.init(x,y,s); + FloatingScore* new_floating_score = new FloatingScore(); + new_floating_score->init(x,y,s); floating_scores.push_back(new_floating_score); } void World::add_bouncy_distro(float x, float y) { - BouncyDistro new_bouncy_distro; - new_bouncy_distro.init(x,y); + BouncyDistro* new_bouncy_distro = new BouncyDistro(); + new_bouncy_distro->init(x,y); bouncy_distros.push_back(new_bouncy_distro); } @@ -413,16 +413,16 @@ World::add_broken_brick(Tile* tile, float x, float y) void World::add_broken_brick_piece(Tile* tile, float x, float y, float xm, float ym) { - BrokenBrick new_broken_brick; - new_broken_brick.init(tile, x, y, xm, ym); + BrokenBrick* new_broken_brick = new BrokenBrick(); + new_broken_brick->init(tile, x, y, xm, ym); broken_bricks.push_back(new_broken_brick); } void World::add_bouncy_brick(float x, float y) { - BouncyBrick new_bouncy_brick; - new_bouncy_brick.init(x,y); + BouncyBrick* new_bouncy_brick = new BouncyBrick(); + new_bouncy_brick->init(x,y); bouncy_bricks.push_back(new_bouncy_brick); } diff --git a/src/world.h b/src/world.h index 62ca1d690..591d30576 100644 --- a/src/world.h +++ b/src/world.h @@ -50,10 +50,10 @@ private: static World* current_; public: - std::vector bouncy_distros; - std::vector broken_bricks; - std::vector bouncy_bricks; - std::vector floating_scores; + std::vector bouncy_distros; + std::vector broken_bricks; + std::vector bouncy_bricks; + std::vector floating_scores; std::vector upgrades; std::vector bullets; -- 2.11.0