From: Ricardo Cruz Date: Thu, 22 Apr 2004 10:43:36 +0000 (+0000) Subject: Applied Ryan's patch for overlaping badguys. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=9dd2c8de7f0df4cbe62c1006354dd7f15675fd74;p=supertux.git Applied Ryan's patch for overlaping badguys. SVN-Revision: 623 --- diff --git a/src/badguy.cpp b/src/badguy.cpp index 2d1de29d9..688d36561 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -1025,6 +1025,26 @@ BadGuy::collision(void *p_c_object, int c_object, CollisionType type) // Jumpy is an exception if (pbad_c->kind == BAD_MONEY) break; + + // Bounce off of other badguy if we land on top of him + if (base.y + base.height < pbad_c->base.y + pbad_c->base.height) + { + Direction old_dir = dir; + if (pbad_c->dir == LEFT) + dir = RIGHT; + else if (pbad_c->dir == RIGHT) + dir = LEFT; + + if (dir != old_dir) + physic.inverse_velocity_x(); + + physic.set_velocity(fabs(physic.get_velocity_x()), 2); + + break; + } + else if (base.y + base.height > pbad_c->base.y + pbad_c->base.height) + break; + if (dir == LEFT) dir = RIGHT; else if (dir == RIGHT)