void Player::do_cheer() { do_duck(); do_backflip(); do_standup(); }
void Player::handle_vertical_input() { // Press jump key if(controller->pressed(Controller::JUMP) && (can_jump)) { if (duck) { // when running, only jump a little bit; else do a backflip if (physic.get_velocity_x() != 0) do_jump(-300); else do_backflip(); } else { // jump a bit higher if we are running; else do a normal jump if (fabs(physic.get_velocity_x()) > MAX_WALK_XM) do_jump(-580); else do_jump(-520); } } // Let go of jump key else if(!controller->hold(Controller::JUMP)) { if (!backflipping && jumping && physic.get_velocity_y() < 0) { jumping = false; physic.set_velocity_y(0); } } /* In case the player has pressed Down while in a certain range of air, enable butt jump action */ if (controller->hold(Controller::DOWN) && !butt_jump && !duck && is_big() && jumping) { butt_jump = true; } /* When Down is not held anymore, disable butt jump */ if(butt_jump && !controller->hold(Controller::DOWN)) butt_jump = false; }
void Player::handle_vertical_input() { // Press jump key if(controller->pressed(Controller::JUMP)) jump_button_timer.start(JUMP_GRACE_TIME); if (((controller->hold(Controller::JUMP) && jump_button_timer.started()) || jump_helper_jump) && can_jump) { jump_button_timer.stop(); if (duck) { // when running, only jump a little bit; else do a backflip if ((physic.get_velocity_x() != 0) || (controller->hold(Controller::LEFT)) || (controller->hold(Controller::RIGHT))) { do_jump(-300); } else { do_backflip(); } } else { // jump a bit higher if we are running; else do a normal jump if (fabs(physic.get_velocity_x()) > MAX_WALK_XM) do_jump(-580); else do_jump(-520); } } // Let go of jump key else if(!(controller->hold(Controller::JUMP) || jump_helper_jump)) { if (!backflipping && jumping && physic.get_velocity_y() < 0) { jumping = false; 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()) { wants_buttjump = true; if (physic.get_velocity_y() >= BUTTJUMP_MIN_VELOCITY_Y) does_buttjump = true; } /* When Down is not held anymore, disable butt jump */ if(!controller->hold(Controller::DOWN)) { wants_buttjump = false; does_buttjump = false; } // swimming physic.set_acceleration_y(0); #ifdef SWIMMING if (swimming) { if (controller->hold(Controller::UP) || controller->hold(Controller::JUMP)) physic.set_acceleration_y(-2000); physic.set_velocity_y(physic.get_velocity_y() * 0.94); } #endif }