From: Ingo Ruhnke Date: Mon, 14 Jun 2004 21:39:58 +0000 (+0000) Subject: - fixed bounce code a bit, should now be useable, bounce high might still need tuning X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;ds=inline;h=a836b975b40b647b66d90a71a3dbbbf27b66f0c6;p=supertux.git - fixed bounce code a bit, should now be useable, bounce high might still need tuning SVN-Revision: 1487 --- diff --git a/src/badguy.cpp b/src/badguy.cpp index daff4ad4e..b9e9c25b7 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -1028,7 +1028,7 @@ BadGuy::bump() void BadGuy::squish_me(Player* player) { - player->bounce(); + player->bounce(this); Sector::current()->add_score(Vector(base.x, base.y), 50 * player_status.score_multiplier); @@ -1050,7 +1050,7 @@ BadGuy::squish(Player* player) // mrbomb transforms into a bomb now explode(false); - player->bounce(); + player->bounce(this); Sector::current()->add_score(Vector(base.x, base.y), 50 * player_status.score_multiplier); sound_manager->play_sound(sounds[SND_SQUISH], get_pos()); @@ -1084,7 +1084,7 @@ BadGuy::squish(Player* player) set_sprite(img_mriceblock_flat_left, img_mriceblock_flat_right); } - player->bounce(); + player->bounce(this); player_status.score_multiplier++; @@ -1101,7 +1101,7 @@ BadGuy::squish(Player* player) if(physic.get_velocity_y() >= 0) return; - player->bounce(); + player->bounce(this); Sector::current()->add_score(Vector(base.x, base.y), 25 * player_status.score_multiplier); @@ -1132,7 +1132,7 @@ BadGuy::squish(Player* player) physic.set_velocity_x(physic.get_velocity_x() * 2.0f); // XXX magic number: 66 is BGM_BIG height - player->bounce(); + player->bounce(this); base.y += 66 - base.height; Sector::current()->add_score(Vector(base.x, base.y), diff --git a/src/player.cpp b/src/player.cpp index e43bd63d6..c42499db9 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -1007,16 +1007,16 @@ Player::check_bounds(Camera* camera) } void -Player::bounce() +Player::bounce(BadGuy* badguy) { if (input.up) physic.set_velocity_y(5.2); else physic.set_velocity_y(2); - // FIXME: moving tux up looks ugly, but without it tux might collide - // FIXME: with enemies, which he has just jump onto (iceblock) - //base.y = base.y - base.height - 2; + // Move the player a little bit above the badguy to avoid collision + // between badguy and player directly after the bounce has happend + base.y = badguy->base.y - base.height - 2; } /* EOF */ diff --git a/src/player.h b/src/player.h index 6805b78d6..0d17af3a7 100644 --- a/src/player.h +++ b/src/player.h @@ -31,6 +31,8 @@ #include "moving_object.h" #include "physic.h" +class BadGuy; + /* Times: */ #define TUX_SAFE_TIME 1250 @@ -183,7 +185,7 @@ public: /** let the player jump a bit or more if jump button is hold down (used when you hit a badguy) */ - void bounce(); + void bounce(BadGuy* badguy); bool is_dead() const { return dead; }