From: Ingo Ruhnke Date: Mon, 14 Jun 2004 18:34:25 +0000 (+0000) Subject: - added jumping from badguys (hold jump pressed while jumping on one) X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=2b69e1dda8897c83569bf0a3a431457ed273aa9d;p=supertux.git - added jumping from badguys (hold jump pressed while jumping on one) SVN-Revision: 1486 --- diff --git a/src/badguy.cpp b/src/badguy.cpp index 100ad815c..daff4ad4e 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -1026,16 +1026,9 @@ BadGuy::bump() } void -BadGuy::make_player_jump(Player* player) -{ - player->physic.set_velocity_y(2); - player->base.y = base.y - player->base.height - 2; -} - -void BadGuy::squish_me(Player* player) { - make_player_jump(player); + player->bounce(); Sector::current()->add_score(Vector(base.x, base.y), 50 * player_status.score_multiplier); @@ -1057,7 +1050,7 @@ BadGuy::squish(Player* player) // mrbomb transforms into a bomb now explode(false); - make_player_jump(player); + player->bounce(); Sector::current()->add_score(Vector(base.x, base.y), 50 * player_status.score_multiplier); sound_manager->play_sound(sounds[SND_SQUISH], get_pos()); @@ -1091,7 +1084,7 @@ BadGuy::squish(Player* player) set_sprite(img_mriceblock_flat_left, img_mriceblock_flat_right); } - make_player_jump(player); + player->bounce(); player_status.score_multiplier++; @@ -1108,7 +1101,7 @@ BadGuy::squish(Player* player) if(physic.get_velocity_y() >= 0) return; - make_player_jump(player); + player->bounce(); Sector::current()->add_score(Vector(base.x, base.y), 25 * player_status.score_multiplier); @@ -1139,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 - make_player_jump(player); + player->bounce(); base.y += 66 - base.height; Sector::current()->add_score(Vector(base.x, base.y), diff --git a/src/badguy.h b/src/badguy.h index 6b1566af4..b9c2d129f 100644 --- a/src/badguy.h +++ b/src/badguy.h @@ -160,9 +160,6 @@ private: * ground */ void fall(); - /** let the player jump a bit (used when you hit a badguy) */ - void make_player_jump(Player* player); - /** Turn enemy into a bomb. To explode right way pass true */ void explode(bool right_away); diff --git a/src/player.cpp b/src/player.cpp index 806ca89e8..e43bd63d6 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -1006,3 +1006,18 @@ Player::check_bounds(Camera* camera) } } +void +Player::bounce() +{ + 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; +} + +/* EOF */ + diff --git a/src/player.h b/src/player.h index dedc6b19c..6805b78d6 100644 --- a/src/player.h +++ b/src/player.h @@ -180,6 +180,11 @@ public: bool tiles_on_air(int tiles); void grow(bool animate); void move(const Vector& vector); + + /** let the player jump a bit or more if jump button is hold down + (used when you hit a badguy) */ + void bounce(); + bool is_dead() const { return dead; }