diff options
Diffstat (limited to 'src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion.lua')
-rw-r--r-- | src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion.lua | 37 |
1 files changed, 26 insertions, 11 deletions
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 fcb617c..903809e 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 @@ -21,9 +21,7 @@ function motionModule.motion(dt) if menu == true then accept(dt) elseif menu == false then - if ground == true then - jump(dt) - end + jump(dt) end elseif love.keyboard.isDown(button.b) then if menu == true then @@ -94,6 +92,23 @@ function pause(dt) end function jump(dt) + if character.bola.jump.velocity == 0 then + character.bola.jump.velocity = character.bola.jump.height + end + + if character.bola.jump.velocity ~= 0 then + 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 + + if character.bola.position.y > character.bola.jump.ground then + character.bola.jump.velocity = 0 + character.bola.position.y = character.bola.jump.ground + end + + quad = { + bola = character.bola.jump[math.floor(character.bola.jump.start)] + } end function hitGround(dt) @@ -118,9 +133,9 @@ function walkLeft(dt) character.bola.acceleration = character.bola.acceleration + dt if character.bola.position.x >= character.bola.origin.x then if character.bola.acceleration < 3 then - character.bola.position.x = character.bola.position.x - (character.bola.speed * dt) - character.bola.acceleration + character.bola.position.x = character.bola.position.x - (character.bola.velocity * dt) - character.bola.acceleration else - character.bola.position.x = character.bola.position.x - (character.bola.speed * dt) - 3 + character.bola.position.x = character.bola.position.x - (character.bola.velocity * dt) - 3 end end quad = { @@ -133,9 +148,9 @@ function walkRight(dt) character.bola.acceleration = character.bola.acceleration + dt if character.bola.position.x <= windowProfile.mode.width - character.bola.origin.x then if character.bola.acceleration < 3 then - character.bola.position.x = character.bola.position.x + (character.bola.speed * dt) + character.bola.acceleration + character.bola.position.x = character.bola.position.x + (character.bola.velocity * dt) + character.bola.acceleration else - character.bola.position.x = character.bola.position.x + (character.bola.speed * dt) + 3 + character.bola.position.x = character.bola.position.x + (character.bola.velocity * dt) + 3 end end quad = { @@ -148,9 +163,9 @@ function walkUp(dt) character.bola.acceleration = character.bola.acceleration + dt if character.bola.position.y >= character.bola.origin.y then if character.bola.acceleration < 3 then - character.bola.position.y = character.bola.position.y - (character.bola.speed * dt) - character.bola.acceleration + character.bola.position.y = character.bola.position.y - (character.bola.velocity * dt) - character.bola.acceleration else - character.bola.position.y = character.bola.position.y - (character.bola.speed * dt) - 3 + character.bola.position.y = character.bola.position.y - (character.bola.velocity * dt) - 3 end end quad = { @@ -162,9 +177,9 @@ function walkDown(dt) character.bola.acceleration = character.bola.acceleration + dt if character.bola.position.y <= windowProfile.mode.height - character.bola.origin.y then if character.bola.acceleration < 3 then - character.bola.position.y = character.bola.position.y + (character.bola.speed * dt) + character.bola.acceleration + character.bola.position.y = character.bola.position.y + (character.bola.velocity * dt) + character.bola.acceleration else - character.bola.position.y = character.bola.position.y + (character.bola.speed * dt) + 3 + character.bola.position.y = character.bola.position.y + (character.bola.velocity * dt) + 3 end end quad = { |