From 652a182790c2220cf34d1e1133afb6de28e7ef19 Mon Sep 17 00:00:00 2001 From: Ryan Flegel Date: Fri, 30 Apr 2004 00:53:35 +0000 Subject: [PATCH] - Fixed jumping so it works in a way everybody can enjoy :) SVN-Revision: 856 --- src/player.cpp | 12 +++++++++--- src/player.h | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/player.cpp b/src/player.cpp index 337313d16..4ff4db4aa 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -82,6 +82,7 @@ Player::init() dying = DYING_NOT; jumping = false; + can_jump = true; frame_main = 0; frame_ = 0; @@ -371,7 +372,8 @@ Player::handle_horizontal_input() void Player::handle_vertical_input() { - if(input.up == DOWN && input.old_up == UP) + // Press jump key + if(input.up == DOWN && can_jump) { if (on_ground()) { @@ -383,15 +385,18 @@ Player::handle_vertical_input() --base.y; jumping = true; + can_jump = false; if (size == SMALL) play_sound(sounds[SND_JUMP], SOUND_CENTER_SPEAKER); else play_sound(sounds[SND_BIGJUMP], SOUND_CENTER_SPEAKER); } } + // Let go of jump key else if(input.up == UP && jumping) { jumping = false; + can_jump = true; if(physic.get_velocity_y() > 0) { physic.set_velocity_y(0); } @@ -406,11 +411,12 @@ Player::handle_input() /* Jump/jumping? */ - if ( input.up == DOWN || (input.up == UP && jumping)) + if (on_ground() && input.up == UP) + can_jump = true; + if (input.up == DOWN || (input.up == UP && jumping)) { handle_vertical_input(); } - input.old_up = input.up; /* Shoot! */ diff --git a/src/player.h b/src/player.h index 7997712d3..c734ff70a 100644 --- a/src/player.h +++ b/src/player.h @@ -66,7 +66,6 @@ struct player_input_type int right; int left; int up; - int old_up; int down; int fire; int old_fire; @@ -119,6 +118,7 @@ public: Direction dir; bool jumping; + bool can_jump; int frame_; int frame_main; -- 2.11.0