diff options
author | Jorge Lopez Seijas <jorginho@riseup.net> | 2016-12-01 22:53:44 +0100 |
---|---|---|
committer | coadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu> | 2016-12-01 19:53:38 -0300 |
commit | 80875485a285be0f44727adfc55999c8989dec04 (patch) | |
tree | 96d6c501b0f460ada524a12904dfd7290a9c4660 | |
parent | 66076f572c2289d7522f56f864013e9a9d6d8d8d (diff) |
Add variable isJumping in jump.lua and limit up and down movement when jump
3 files changed, 16 insertions, 5 deletions
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua index a0eafdb..3a7f8b7 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua @@ -29,8 +29,10 @@ function love.keypressed(key, scancode, isrepeat) love.event.quit() end - if scancode == button.a then + if scancode == button.a then character.bola.actionA = true + character.bola.actionDown = false + character.bola.actionUp = false end if scancode == button.left then @@ -41,11 +43,11 @@ function love.keypressed(key, scancode, isrepeat) character.bola.actionRight = true end - if scancode == button.up then - character.bola.actionUp = true + if scancode == button.up and character.bola.jump.isJumping == false then + character.bola.actionUp = true end - if scancode == button.down then + if scancode == button.down and character.bola.jump.isJumping == false then character.bola.actionDown = true end end @@ -76,7 +78,7 @@ function love.keyreleased(key, scancode) end if scancode == button.a then - character.bola.actionA = false + character.bola.actionA = false if character.bola.jump.velocity ~= 0 then character.bola.jump.limitButtonJump = true 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 af8388a..a8c927a 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 @@ -6,6 +6,7 @@ end function gravity(dt) if character.bola.jump.velocity ~= 0 then + character.bola.jump.isJumping = true character.bola.position.y = character.bola.position.y + (character.bola.jump.velocity * dt) character.bola.jump.velocity = character.bola.jump.velocity - (character.bola.gravity * dt) end @@ -16,7 +17,14 @@ function gravity(dt) character.bola.jump.higher = character.bola.jump.higherMax character.bola.jump.limitButtonJump = false + character.bola.jump.isJumping = false character.bola.actionA = false + + if love.keyboard.isScancodeDown(button.up) then + character.bola.actionUp = true + elseif love.keyboard.isScancodeDown(button.down) then + character.bola.actionDown = true + end 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 d7d81b7..b69224e 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 @@ -8,4 +8,5 @@ return { higher = 0.15, higherMax = 0.15, limitButtonJump = false, + isJumping = false, } |