/** if Tux cannot unduck for this long, he will get hurt */
static const float UNDUCK_HURT_TIME = 0.25f;
+/** gravity is higher after the jump key is released before
+ the apex of the jump is reached */
+static const float JUMP_EARLY_APEX_FACTOR = 3.0;
namespace{
bool no_water = true;
last_ground_y = 0;
fall_mode = ON_GROUND;
jumping = false;
+ jump_early_apex = false;
can_jump = true;
wants_buttjump = false;
does_buttjump = false;
}
void
+Player::early_jump_apex() {
+ if(jump_early_apex) {
+ return;
+ }
+ jump_early_apex = true;
+ physic.set_gravity(physic.get_gravity() * JUMP_EARLY_APEX_FACTOR);
+};
+
+void
+Player::do_jump_apex() {
+ if(!jump_early_apex) {
+ return;
+ }
+ jump_early_apex = false;
+ physic.set_gravity(physic.get_gravity() / JUMP_EARLY_APEX_FACTOR);
+}
+
+void
Player::handle_vertical_input()
{
// Press jump key
else if(!controller->hold(Controller::JUMP)) {
if (!backflipping && jumping && physic.get_velocity_y() < 0) {
jumping = false;
- physic.set_velocity_y(0);
+ early_jump_apex();
}
}
+ if(jump_early_apex && physic.get_velocity_y() >= 0) {
+ do_jump_apex();
+ }
+
/* In case the player has pressed Down while in a certain range of air,
enable butt jump action */
if (controller->hold(Controller::DOWN) && !duck && is_big() && !on_ground()) {
bool swimming;
float speedlimit;
Controller* scripting_controller_old; /**< Saves the old controller while the scripting_controller is used */
+ bool jump_early_apex;
public:
Direction dir;
void deactivate();
void walk(float speed);
+ void do_jump_apex();
+ void early_jump_apex();
+
/**
* slows Tux down a little, based on where he's standing
*/