From: Christoph Sommer Date: Wed, 7 Mar 2007 22:40:42 +0000 (+0000) Subject: Experimental modification of jumping behaviour X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=b9235b324ce591ccdcd2ddf0886fcb734d4b1691;p=supertux.git Experimental modification of jumping behaviour SVN-Revision: 4932 --- diff --git a/src/object/player.cpp b/src/object/player.cpp index d070c2952..c3d76f212 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -572,7 +572,7 @@ void Player::handle_vertical_input() { // Press jump key - if(controller->pressed(Controller::JUMP) && (can_jump)) { + if(controller->hold(Controller::JUMP) && (on_ground()) && (can_jump)) { if (duck) { // when running, only jump a little bit; else do a backflip if ((physic.get_velocity_x() != 0) || (controller->hold(Controller::LEFT)) || (controller->hold(Controller::RIGHT))) do_jump(-300); else do_backflip(); @@ -638,8 +638,7 @@ Player::handle_input() if (!backflipping) handle_horizontal_input(); /* Jump/jumping? */ - if (on_ground() && !controller->hold(Controller::JUMP)) - can_jump = true; + if (!controller->hold(Controller::JUMP)) can_jump = true; /* Handle vertical movement: */ handle_vertical_input(); @@ -1081,6 +1080,7 @@ Player::collision(GameObject& other, const CollisionHit& hit) BadGuy* badguy = dynamic_cast (&other); if(badguy != NULL) { + if (hit.bottom) on_ground_flag = true; if(safe_timer.started() || invincible_timer.started()) return FORCE_MOVE; @@ -1228,9 +1228,9 @@ Player::add_velocity(const Vector& velocity, const Vector& end_speed) void Player::bounce(BadGuy& ) { - if(controller->hold(Controller::JUMP)) - physic.set_velocity_y(-520); - else + //if(controller->hold(Controller::JUMP)) + // physic.set_velocity_y(-520); + //else physic.set_velocity_y(-300); } diff --git a/src/object/trampoline.cpp b/src/object/trampoline.cpp index 4871cf639..bed8a1d0b 100644 --- a/src/object/trampoline.cpp +++ b/src/object/trampoline.cpp @@ -79,6 +79,7 @@ Trampoline::collision(GameObject& other, const CollisionHit& hit) vy = VY_INITIAL; } player->physic.set_velocity_y(vy); + player->can_jump = false; sound_manager->play(TRAMPOLINE_SOUND); sprite->set_action("swinging", 1); return FORCE_MOVE;