From: Marek Moeckel Date: Fri, 8 Oct 2004 15:33:54 +0000 (+0000) Subject: when flapping, Tux' x-velocity decreases slowly now X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=68a52fe0728d91fd35a4e7ba68c836158590d67e;p=supertux.git when flapping, Tux' x-velocity decreases slowly now values still need some adjustment, and changing directions while flapping doesn't work yet. SVN-Revision: 1995 --- diff --git a/src/player.cpp b/src/player.cpp index f382efff4..7872c4d75 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -590,14 +590,18 @@ Player::handle_vertical_input() can_flap = false; falling_from_flap = true; } - //TODO: The slowing down of Tux should be handled... - if (physic.get_velocity_x() > 0) {physic.set_velocity_x(WALK_SPEED);} - else if (physic.get_velocity_x() < 0) {physic.set_velocity_x(WALK_SPEED * (-1));} jumping = true; flapping = true; + float iv = physic.get_velocity_x(); + float fv = 1.2; + float cv = 0; + if (iv < 0) {fv *= (-1);} if (flapping_timer.get_gone() <= TUX_FLAPPING_TIME) { - //TODO: ...here, using get_gone to slow him down at an increasing rate + //FIXME: Changing directions while flapping doesn't work yet + if (iv == 0) {cv = 0;} + else {cv = (iv-((iv-fv)*(float)flapping_timer.get_gone()/TUX_FLAPPING_TIME));} + physic.set_velocity_x(cv); physic.set_velocity_y((float)flapping_timer.get_gone()/700); } }