Update of /cvsroot/super-tux/supertux/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17899/src
Modified Files:
player.cpp
Log Message:
- tweaked flapping a bit, let me know what you think
- 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
Index: player.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v
retrieving revision 1.180
retrieving revision 1.181
diff -u -d -r1.180 -r1.181
--- player.cpp 4 Oct 2004 21:13:16 -0000 1.180
+++ player.cpp 6 Oct 2004 05:20:07 -0000 1.181
@@ -581,15 +581,27 @@
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 @@
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;
|