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 | 52 |
1 files changed, 52 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..caf602b --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion.lua @@ -0,0 +1,52 @@ +local motionModule = {} + +function motionModule.motion(dt) + if love.keyboard.isDown(button.left) then + left(dt) + elseif love.keyboard.isDown(button.right) then + right(dt) + elseif love.keyboard.isDown(button.down) then + down(dt) + else + stand(dt) + end +end + +function left(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 + else + character.bola.position.x = character.bola.position.x - (character.bola.speed * dt) - 3 + end + end + quad = character.bola.walk[math.floor(character.bola.walk.start)] + character.bola.scale.x = -1 +end + +function right(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 + else + character.bola.position.x = character.bola.position.x + (character.bola.speed * dt) + 3 + end + end + quad = character.bola.walk[math.floor(character.bola.walk.start)] + character.bola.scale.x = 1 +end + +function down(dt) + character.bola.acceleration = 0 + transform.bola.origin.y = character.bola.origin.y - character.bola.origin.y + quad = character.bola.crouch[1] +end + +function stand(dt) + character.bola.acceleration = 0 + quad = character.bola.stand[math.floor(character.bola.stand.start)] +end + +return motionModule |