Player::handle_vertical_input()
{
// Press jump key
- if(controller->pressed(Controller::JUMP) && (can_jump)) {
+ if(controller->hold(Controller::JUMP) && (on_ground()) && (can_jump)) {
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();
if (!backflipping) handle_horizontal_input();
/* Jump/jumping? */
- if (on_ground() && !controller->hold(Controller::JUMP))
- can_jump = true;
+ if (!controller->hold(Controller::JUMP)) can_jump = true;
/* Handle vertical movement: */
handle_vertical_input();
BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
if(badguy != NULL) {
+ if (hit.bottom) on_ground_flag = true;
if(safe_timer.started() || invincible_timer.started())
return FORCE_MOVE;
void
Player::bounce(BadGuy& )
{
- if(controller->hold(Controller::JUMP))
- physic.set_velocity_y(-520);
- else
+ //if(controller->hold(Controller::JUMP))
+ // physic.set_velocity_y(-520);
+ //else
physic.set_velocity_y(-300);
}
vy = VY_INITIAL;
}
player->physic.set_velocity_y(vy);
+ player->can_jump = false;
sound_manager->play(TRAMPOLINE_SOUND);
sprite->set_action("swinging", 1);
return FORCE_MOVE;