when flapping, Tux' x-velocity decreases slowly now
[supertux.git] / src / player.cpp
index 5e33cc8..7872c4d 100644 (file)
@@ -577,7 +577,36 @@ Player::handle_vertical_input()
          }
     }
 
-   // Flapping
+   
+   // Flapping, Marek's version
+   if (input.jump == DOWN && can_flap)
+     {
+         if (!flapping_timer.started())
+            {
+               flapping_timer.start(TUX_FLAPPING_TIME);
+            }
+         if (!flapping_timer.check()) 
+            {
+               can_flap = false;
+               falling_from_flap = true;
+            }
+         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)
+            {
+               //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);
+            }
+     }
+     
+   /* // Flapping, Ryan's version
    if (input.jump == DOWN && can_flap)
      {
          if (!flapping_timer.started())
@@ -589,8 +618,6 @@ Player::handle_vertical_input()
                can_flap = false;
                falling_from_flap = true;
             }
-         //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;
          if (flapping && flapping_timer.get_gone() <= TUX_FLAPPING_TIME
@@ -599,8 +626,6 @@ Player::handle_vertical_input()
                float gravity = Sector::current()->gravity;
                float xr = (fabsf(physic.get_velocity_x()) / MAX_RUN_XM);
 
-               //physic.set_velocity_y((float)flapping_timer.get_gone()/700);
-
                // XXX: magic numbers. should be a percent of gravity
                //      gravity is (by default) -0.1f
                physic.set_acceleration_y(.12 + .01f*xr);
@@ -621,6 +646,7 @@ Player::handle_vertical_input()
      {
         physic.set_acceleration_y(0);
      }
+   */
 
    // Hover
    //(disabled by default, use cheat code "hover" to toggle on/off)