From 2c59f4307245cfa2298145910dff5428c2af9fbe Mon Sep 17 00:00:00 2001 From: André Fabian Silva Delgado Date: Sat, 26 Nov 2016 20:52:38 -0300 Subject: Move {gravity,motion}.lua from scripts/bola/motion to scripts/bola --- .../main.lua | 4 +-- .../scripts/bola/gravity.lua | 20 ++++++++++++ .../scripts/bola/motion.lua | 37 ++++++++++++++++++++++ .../scripts/bola/motion/gravity.lua | 20 ------------ .../scripts/bola/motion/motion.lua | 37 ---------------------- 5 files changed, 59 insertions(+), 59 deletions(-) create mode 100644 src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/gravity.lua create mode 100644 src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion.lua delete mode 100644 src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/gravity.lua delete mode 100644 src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/motion.lua diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua index 31818af..c54f601 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua @@ -17,8 +17,8 @@ function love.load() } bolaAnimation = require 'scripts.bola.animation' - bolaMotion = require 'scripts.bola.motion.motion' - bolaGravity = require 'scripts.bola.motion.gravity' + bolaMotion = require 'scripts.bola.motion' + bolaGravity = require 'scripts.bola.gravity' end function love.keypressed(key) 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 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 diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/gravity.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/gravity.lua deleted file mode 100644 index 98ba985..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/gravity.lua +++ /dev/null @@ -1,20 +0,0 @@ -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 diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/motion.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/motion.lua deleted file mode 100644 index 89d3832..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/motion.lua +++ /dev/null @@ -1,37 +0,0 @@ -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 -- cgit v1.2.3-54-g00ecf