- tweaked flapping a bit, let me know what you think
authorRyan Flegel <rflegel@gmail.com>
Wed, 6 Oct 2004 05:20:07 +0000 (05:20 +0000)
committerRyan Flegel <rflegel@gmail.com>
Wed, 6 Oct 2004 05:20:07 +0000 (05:20 +0000)
   - it currently sets y accel to 0.5 + 0.6*xr to float
   - 0.5 is the minimum acceleration upwards (vs gravity)
   - 0.6 is how much more you can achieve with maximum x velocity
   - xr is a ratio of x-vel/max-x-vel
   - default gravity is -0.1, so at max speed with flapping you slowly gain
     a little height

SVN-Revision: 1982

src/player.cpp

index 6ac1971..666616b 100644 (file)
@@ -581,15 +581,27 @@ 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));}
+         //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_timer.get_gone() <= TUX_FLAPPING_TIME)
+         if (flapping && flapping_timer.get_gone() <= TUX_FLAPPING_TIME
+                && physic.get_velocity_y() < 0)
             {
-               physic.set_velocity_y((float)flapping_timer.get_gone()/700);
+               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(.05 + .06f*xr);
             }
      }
+    else
+     {
+        physic.set_acceleration_y(0);
+     }
    
    // Hover
    //(disabled by default, use cheat code "hover" to toggle on/off)
@@ -670,6 +682,8 @@ Player::handle_vertical_input()
       flapping = false;
       falling_from_flap = false;
       if (flapping_timer.started()) {flapping_timer.stop();}
+
+      physic.set_acceleration_y(0); //for flapping
     }
 
   input.old_up = input.up;