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, 37 insertions, 0 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 new file mode 100644 index 0000000..89d3832 --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion.lua @@ -0,0 +1,37 @@ +local motionModule = {} + +function motionModule.motion(dt) + if character.bola.jump.higher > 0 and love.keyboard.isScancodeDown(button.a) then + jump(dt) + end + if love.keyboard.isScancodeDown(button.left) then + walkLeft(dt) + elseif love.keyboard.isScancodeDown(button.right) then + walkRight(dt) + end +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) + +-- quad.bola = character.bola.jump[math.floor(character.bola.jump.start)] +end + +function walkLeft(dt) + if character.bola.position.x >= character.bola.origin.x then + character.bola.position.x = character.bola.position.x - (character.bola.velocity * dt) + end + quad.bola = character.bola.walk[math.floor(character.bola.walk.start)] + character.bola.scale.x = -1 +end + +function walkRight(dt) + if character.bola.position.x <= windowProfile.mode.width - character.bola.origin.x then + character.bola.position.x = character.bola.position.x + (character.bola.velocity * dt) + end + quad.bola = character.bola.walk[math.floor(character.bola.walk.start)] + character.bola.scale.x = 1 +end + +return motionModule |