diff options
author | coadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu> | 2016-11-24 10:51:28 -0300 |
---|---|---|
committer | coadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu> | 2016-11-24 15:42:39 -0300 |
commit | 36f43df916516bf9284c6567849a4331bef4a553 (patch) | |
tree | 01aba12cac96bdc4313ceb1331237d1ea7cd479c | |
parent | a443b66c8f7ffd0ca31472bf2f8331e35d7e1b70 (diff) |
Rename left() to walkLeft(), right() to walkRight() and add walkUp() walkDown()
-rw-r--r-- | src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion.lua | 51 |
1 files changed, 42 insertions, 9 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 64bc1c7..61f0ce0 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 @@ -1,18 +1,23 @@ local motionModule = {} function motionModule.motion(dt) - if love.keyboard.isDown(button.left) then - left(dt) - elseif love.keyboard.isScancodeDown(button.right) then - right(dt) - elseif love.keyboard.isScancodeDown(button.down) then - crouch(dt) + if love.keyboard.isDown(button.left) or love.keyboard.isScancodeDown(button.right) or love.keyboard.isScancodeDown(button.up) or love.keyboard.isScancodeDown(button.down) then + if love.keyboard.isDown(button.left) then + walkLeft(dt) + elseif love.keyboard.isScancodeDown(button.right) then + walkRight(dt) + end + if love.keyboard.isScancodeDown(button.up) then + walkUp(dt) + elseif love.keyboard.isScancodeDown(button.down) then + walkDown(dt) + end else - stand(dt) + stand(dt) end end -function left(dt) +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 @@ -27,7 +32,7 @@ function left(dt) character.bola.scale.x = -1 end -function right(dt) +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 @@ -42,6 +47,34 @@ function right(dt) character.bola.scale.x = 1 end +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 + else + character.bola.position.y = character.bola.position.y - (character.bola.speed * dt) - 3 + end + end + quad = { + bola = character.bola.walk[math.floor(character.bola.walk.start)] + } +end + +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 + else + character.bola.position.y = character.bola.position.y + (character.bola.speed * dt) + 3 + end + end + quad = { + bola = character.bola.walk[math.floor(character.bola.walk.start)] + } +end + function crouchDown(dt) character.bola.acceleration = 0 transform.bola.origin.y = character.bola.origin.crouchDown.y[math.floor(character.bola.crouchDown.start)] |