diff options
Diffstat (limited to 'src')
5 files changed, 40 insertions, 40 deletions
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/gravity.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/gravity.lua new file mode 100644 index 0000000..42fd2d9 --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/gravity.lua @@ -0,0 +1,23 @@ +game.gravity = function(character, dt) + if character.jump.velocity ~= 0 then + character.jump.isJumping = true + character.position.y = character.position.y + (character.jump.velocity * dt) + character.jump.velocity = character.jump.velocity - (character.gravity * dt) + end + + if character.position.y > character.jump.ground then + character.jump.velocity = 0 + character.position.y = character.jump.ground + character.jump.higher = character.jump.higherMax + + character.jump.limitButtonJump = false + character.jump.isJumping = false + character.actionA = false + + if love.keyboard.isScancodeDown(button.up) then + character.actionUp = true + elseif love.keyboard.isScancodeDown(button.down) then + character.actionDown = true + end + end +end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/limit.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/limit.lua new file mode 100644 index 0000000..4cd94f2 --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/limit.lua @@ -0,0 +1,13 @@ +game.limit = function(character, dt) + if character.position.x <= character.origin.x then + character.position.x = character.origin.x + elseif character.position.x >= windowProfile.mode.width - character.origin.x then + character.position.x = windowProfile.mode.width - character.origin.x + end + + if character.position.y <= character.origin.y then + character.position.y = character.origin.y + elseif character.position.y >= windowProfile.mode.height - character.origin.y then + character.position.y = windowProfile.mode.height - character.origin.y + end +end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/default.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/default.lua index de1592f..9593a45 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/default.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/default.lua @@ -1,11 +1,11 @@ require 'scripts.update.fps' require 'scripts.game.motion' -require 'scripts.update.gravity' -require 'scripts.update.limit' +require 'scripts.game.gravity' +require 'scripts.game.limit' main.update = function(dt) update.fps() game.motion(metaSprites.bola, character.bola, dt) - update.gravity(dt) - update.limit(dt) + game.gravity(character.bola, dt) + game.limit(character.bola, dt) end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/gravity.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/gravity.lua deleted file mode 100644 index 7e28588..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/gravity.lua +++ /dev/null @@ -1,23 +0,0 @@ -update.gravity = function(dt) - if character.bola.jump.velocity ~= 0 then - character.bola.jump.isJumping = true - 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 - - character.bola.jump.limitButtonJump = false - character.bola.jump.isJumping = false - character.bola.actionA = false - - if love.keyboard.isScancodeDown(button.up) then - character.bola.actionUp = true - elseif love.keyboard.isScancodeDown(button.down) then - character.bola.actionDown = true - end - end -end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/limit.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/limit.lua deleted file mode 100644 index 3990db0..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/limit.lua +++ /dev/null @@ -1,13 +0,0 @@ -update.limit = function(dt) - if character.bola.position.x <= character.bola.origin.x then - character.bola.position.x = character.bola.origin.x - elseif character.bola.position.x >= windowProfile.mode.width - character.bola.origin.x then - character.bola.position.x = windowProfile.mode.width - character.bola.origin.x - end - - if character.bola.position.y <= character.bola.origin.y then - character.bola.position.y = character.bola.origin.y - elseif character.bola.position.y >= windowProfile.mode.height - character.bola.origin.y then - character.bola.position.y = windowProfile.mode.height - character.bola.origin.y - end -end |