From b109b2bffc5e5497b248c9f43e7da93f9e1ea785 Mon Sep 17 00:00:00 2001 From: Jorge Lopez Seijas Date: Mon, 28 Nov 2016 21:49:30 +0100 Subject: Fix jump continuous press button a --- .../scripts/bola/gravity.lua | 1 + .../scripts/bola/jump.lua | 1 + .../scripts/bola/motion.lua | 11 ++++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src/gnu_and_bola_-_the_libre_beat_em_up_game') diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/gravity.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/gravity.lua index 98ba985..d023bed 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/gravity.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/gravity.lua @@ -14,6 +14,7 @@ function gravity(dt) character.bola.jump.velocity = 0 character.bola.position.y = character.bola.jump.ground character.bola.jump.higher = character.bola.jump.higherMax + character.bola.jump.finishJump = true end end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/jump.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/jump.lua index 42c1868..fe6646b 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/jump.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/jump.lua @@ -7,4 +7,5 @@ return { ground = windowProfile.mode.height / 2, higher = 0.15, higherMax = 0.15, + finishJump = false, } diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion.lua index e0d5465..109b873 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion.lua @@ -3,7 +3,10 @@ local motionModule = {} function motionModule.motion(dt) if character.bola.jump.higher > 0 and love.keyboard.isScancodeDown(button.a) then jump(dt) + else + character.bola.jump.finishJump = false end + if love.keyboard.isScancodeDown(button.left) then walkLeft(dt) elseif love.keyboard.isScancodeDown(button.right) then @@ -17,10 +20,12 @@ function motionModule.motion(dt) end function jump(dt) - character.bola.jump.higher = character.bola.jump.higher - dt - character.bola.jump.velocity = character.bola.jump.velocity + character.bola.jump.height * (dt / character.bola.jump.higherMax) + if character.bola.jump.finishJump == false then + character.bola.jump.higher = character.bola.jump.higher - dt + character.bola.jump.velocity = character.bola.jump.velocity + character.bola.jump.height * (dt / character.bola.jump.higherMax) --- quad.bola = character.bola.jump[math.floor(character.bola.jump.start)] + -- quad.bola = character.bola.jump[math.floor(character.bola.jump.start)] + end end function walkLeft(dt) -- cgit v1.2.3-54-g00ecf