diff options
author | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-11-26 10:45:50 -0300 |
---|---|---|
committer | coadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu> | 2016-11-26 12:16:00 -0300 |
commit | a823e60d78dafcc177604976dfb9753a84950b33 (patch) | |
tree | cf0387c4d13a1a54144059fc19f2ec566e0cdcf4 /src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts | |
parent | db1a6b18423356a9c8dd92ccd83dab42350ab876 (diff) |
Begin modularize motion
* modularize gravity to fix jumping
* remove acceleration, walking up and walking down for now to make testing more easily
Diffstat (limited to 'src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts')
3 files changed, 157 insertions, 197 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 deleted file mode 100644 index 903809e..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion.lua +++ /dev/null @@ -1,197 +0,0 @@ -local motionModule = {} - -menu = false - -function motionModule.motion(dt) - if love.keyboard.isDown(button.start) then - if menu == true then - accept(dt) - elseif menu == false then - pause(dt) - end - elseif love.keyboard.isDown(button.select) then - if arcade == true then - coin(dt) - elseif arcade == false then - if menu == true then - select(dt) - end - end - elseif love.keyboard.isDown(button.a) then - if menu == true then - accept(dt) - elseif menu == false then - jump(dt) - end - elseif love.keyboard.isDown(button.b) then - if menu == true then - if acceptOnly == true then - accept(dt) - elseif acceptOnly == false then - if gameContinue == true then - dropContinueCount(dt) - elseif gameContinue == false then - cancel(dt) - end - end - elseif menu == false then - if ground == true then - hitGround(dt) - elseif ground == false then - hitAir(dt) - end - end - elseif love.keyboard.isDown(button.left, button.right, button.up, button.down) then - if menu == true then - if love.keyboard.isDown(button.left) then - selectLeft(dt) - elseif love.keyboard.isScancodeDown(button.right) then - selectRight(dt) - end - if love.keyboard.isScancodeDown(button.up) then - selectUp(dt) - elseif love.keyboard.isScancodeDown(button.down) then - selectDown(dt) - end - elseif menu == false then - if love.keyboard.isDown(button.left) then - walkLeft(dt) - elseif love.keyboard.isScancodeDown(button.right) then - walkRight(dt) - end - if love.keyboard.isScancodeDown(button.up) then - walkUp(dt) - elseif love.keyboard.isScancodeDown(button.down) then - walkDown(dt) - end - end - else - stand(dt) - end -end - -function configuration(dt) -end - -function coin(dt) -end - -function accept(dt) -end - -function cancel(dt) -end - -function select(dt) -end - -function dropContinueCount(dt) -end - -function pause(dt) -end - -function jump(dt) - if character.bola.jump.velocity == 0 then - character.bola.jump.velocity = character.bola.jump.height - end - - 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 - end - - quad = { - bola = character.bola.jump[math.floor(character.bola.jump.start)] - } -end - -function hitGround(dt) -end - -function hitAir(dt) -end - -function selectLeft(dt) -end - -function selectRight(dt) -end - -function selectUp(dt) -end - -function selectDown(dt) -end - -function walkLeft(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.velocity * dt) - character.bola.acceleration - else - character.bola.position.x = character.bola.position.x - (character.bola.velocity * dt) - 3 - end - end - quad = { - bola = character.bola.walk[math.floor(character.bola.walk.start)] - } - character.bola.scale.x = -1 -end - -function walkRight(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.velocity * dt) + character.bola.acceleration - else - character.bola.position.x = character.bola.position.x + (character.bola.velocity * dt) + 3 - end - end - quad = { - bola = character.bola.walk[math.floor(character.bola.walk.start)] - } - character.bola.scale.x = 1 -end - -function walkUp(dt) - character.bola.acceleration = character.bola.acceleration + dt - if character.bola.position.y >= character.bola.origin.y then - if character.bola.acceleration < 3 then - character.bola.position.y = character.bola.position.y - (character.bola.velocity * dt) - character.bola.acceleration - else - character.bola.position.y = character.bola.position.y - (character.bola.velocity * dt) - 3 - end - end - quad = { - bola = character.bola.walk[math.floor(character.bola.walk.start)] - } -end - -function walkDown(dt) - character.bola.acceleration = character.bola.acceleration + dt - if character.bola.position.y <= windowProfile.mode.height - character.bola.origin.y then - if character.bola.acceleration < 3 then - character.bola.position.y = character.bola.position.y + (character.bola.velocity * dt) + character.bola.acceleration - else - character.bola.position.y = character.bola.position.y + (character.bola.velocity * dt) + 3 - end - end - quad = { - bola = character.bola.walk[math.floor(character.bola.walk.start)] - } -end - -function stand(dt) - character.bola.acceleration = 0 - quad = { - bola = character.bola.stand[math.floor(character.bola.stand.start)] - } -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 new file mode 100644 index 0000000..4cc76c4 --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/gravity.lua @@ -0,0 +1,19 @@ +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 + 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 new file mode 100644 index 0000000..355e09a --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/motion/motion.lua @@ -0,0 +1,138 @@ +local motionModule = {} + +menu = false + +function motionModule.motion(dt) + if love.keyboard.isDown(button.start) then + if menu == true then + accept(dt) + elseif menu == false then + pause(dt) + end + elseif love.keyboard.isDown(button.select) then + if arcade == true then + coin(dt) + elseif arcade == false then + if menu == true then + select(dt) + end + end + elseif love.keyboard.isDown(button.a) then + if menu == true then + accept(dt) + elseif menu == false then + jump(dt) + end + elseif love.keyboard.isDown(button.b) then + if menu == true then + if acceptOnly == true then + accept(dt) + elseif acceptOnly == false then + if gameContinue == true then + dropContinueCount(dt) + elseif gameContinue == false then + cancel(dt) + end + end + elseif menu == false then + if ground == true then + hitGround(dt) + elseif ground == false then + hitAir(dt) + end + end + elseif love.keyboard.isDown(button.left, button.right) then + if menu == true then + if love.keyboard.isDown(button.left) then + selectLeft(dt) + elseif love.keyboard.isScancodeDown(button.right) then + selectRight(dt) + end + elseif menu == false then + if love.keyboard.isDown(button.left) then + walkLeft(dt) + elseif love.keyboard.isScancodeDown(button.right) then + walkRight(dt) + end + end + else + stand(dt) + end +end + +function configuration(dt) +end + +function coin(dt) +end + +function accept(dt) +end + +function cancel(dt) +end + +function select(dt) +end + +function dropContinueCount(dt) +end + +function pause(dt) +end + +function hitGround(dt) +end + +function hitAir(dt) +end + +function selectLeft(dt) +end + +function selectRight(dt) +end + +function selectUp(dt) +end + +function selectDown(dt) +end + +function jump(dt) + if character.bola.jump.velocity == 0 then + character.bola.jump.velocity = character.bola.jump.height + end + + 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 + +function stand(dt) + quad = { + bola = character.bola.stand[math.floor(character.bola.stand.start)] + } +end + +return motionModule |