diff options
Diffstat (limited to 'src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion.lua')
-rw-r--r-- | src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion.lua | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion.lua new file mode 100644 index 0000000..80e5b50 --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion.lua @@ -0,0 +1,76 @@ +update.motion = function(dt) + game.animation(character.bola.stand) + quad = {} + quad.bola = character.bola.stand[character.bola.stand.currentFrame] + + if character.bola.jump.higher > 0 and character.bola.actionA == true then + jump(dt) + end + + if character.bola.actionLeft == true and character.bola.actionRight == false then + walkLeft(dt) + end + + if character.bola.actionRight == true and character.bola.actionLeft == false then + walkRight(dt) + end + + if character.bola.actionLeft == true and character.bola.actionRight == true then + stand(dt) + end + + if character.bola.actionUp == true and character.bola.actionDown == false then + walkUp(dt) + end + + if character.bola.actionDown == true and character.bola.actionUp == false then + walkDown(dt) + end + + if character.bola.actionUp == true and character.bola.actionDown == true then + stand(dt) + end +end + +function jump(dt) + if character.bola.jump.limitButtonJump == false then + 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) + + -- game.animation(character.bola.jump) + -- quad.bola = character.bola.jump[character.bola.jump.currentFrame] + end +end + +function stand(dt) + game.animation(character.bola.stand) + quad.bola = character.bola.stand[character.bola.stand.currentFrame] +end + +function walkLeft(dt) + character.bola.position.x = character.bola.position.x - (character.bola.velocity * dt) + game.animation(character.bola.walk) + quad.bola = character.bola.walk[character.bola.walk.currentFrame] + character.bola.scale.x = -1 +end + +function walkRight(dt) + character.bola.position.x = character.bola.position.x + (character.bola.velocity * dt) + game.animation(character.bola.walk) + quad.bola = character.bola.walk[character.bola.walk.currentFrame] + character.bola.scale.x = 1 +end + +function walkUp(dt) + character.bola.position.y = character.bola.position.y - (character.bola.velocity * dt) + character.bola.jump.ground = character.bola.position.y + game.animation(character.bola.walk) + quad.bola = character.bola.walk[character.bola.walk.currentFrame] +end + +function walkDown(dt) + character.bola.position.y = character.bola.position.y + (character.bola.velocity * dt) + character.bola.jump.ground = character.bola.position.y + game.animation(character.bola.walk) + quad.bola = character.bola.walk[character.bola.walk.currentFrame] +end |