diff options
author | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-12-06 11:44:09 -0300 |
---|---|---|
committer | coadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu> | 2016-12-06 18:50:10 -0300 |
commit | 1e02fcb40d10b4f82fd726b01b4ffbffaf7c5463 (patch) | |
tree | b7bfa550dc601b7142f1e2cd5b526c1e22f094a7 /src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game | |
parent | a51811542757130be1832beb21580bea4d24654e (diff) |
Keep the code more KISS - part 7
Diffstat (limited to 'src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game')
-rw-r--r-- | src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/gravity.lua | 23 | ||||
-rw-r--r-- | src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/limit.lua | 13 |
2 files changed, 36 insertions, 0 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 |