diff options
Diffstat (limited to 'src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/gravity.lua')
-rw-r--r-- | src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/gravity.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/gravity.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/gravity.lua new file mode 100644 index 0000000..98ba985 --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/gravity.lua @@ -0,0 +1,20 @@ +local gravityModule = {} + +function gravityModule.motion(dt) + gravity(dt) +end + +function gravity(dt) + 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 + character.bola.jump.higher = character.bola.jump.higherMax + end +end + +return gravityModule |