diff options
author | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-12-04 13:37:45 -0300 |
---|---|---|
committer | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-12-04 15:35:51 -0300 |
commit | 1e0b3afcb1074f7ca6a52ec1c3aefb76b8d2c08d (patch) | |
tree | 7968f4d186273fc31a302ecbb26a114de61fd29e | |
parent | be92c47794d735812daca917fb1ff6b0d621f948 (diff) |
Keep the code more KISS - part 6
29 files changed, 170 insertions, 164 deletions
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 7920f28..fc8fc51 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 @@ -1,4 +1,9 @@ -require 'scripts.module.default' +require 'scripts.tables' +require 'scripts.load.default' +require 'scripts.keypressed.default' +require 'scripts.keyreleased.default' +require 'scripts.update.default' +require 'scripts.draw.default' function love.load() main.load() diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/draw/default.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/draw/default.lua index 84112dc..9f148f8 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/draw/default.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/draw/default.lua @@ -1,3 +1,8 @@ +require 'scripts.draw.fps' +require 'scripts.draw.scale' +require 'scripts.draw.printFPS' +require 'scripts.game.draw' + main.draw = function() draw.fps() draw.scale() diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/jump.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/jump.lua new file mode 100644 index 0000000..1891af5 --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/jump.lua @@ -0,0 +1,9 @@ +game.jump = function(metaSprites, character, dt) + if character.jump.limitButtonJump == false then + character.jump.higher = character.jump.higher - dt + character.jump.velocity = character.jump.velocity + character.jump.height * (dt / character.jump.higherMax) + + -- game.animation(character.jump, dt) + -- metaSprites.quad = character.jump[character.jump.currentFrame] + end +end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/keypressed.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/keypressed.lua new file mode 100644 index 0000000..1035b05 --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/keypressed.lua @@ -0,0 +1,29 @@ +game.keypressed = function(character, key, scancode, isrepeat) + isrepeat = true + + if scancode == button.quit then + love.event.quit() + end + + if scancode == button.a then + character.actionA = true + character.actionDown = false + character.actionUp = false + end + + if scancode == button.left then + character.actionLeft = true + end + + if scancode == button.right then + character.actionRight = true + end + + if scancode == button.up and character.jump.isJumping == false then + character.actionUp = true + end + + if scancode == button.down and character.jump.isJumping == false then + character.actionDown = true + end +end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/keyreleased.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/keyreleased.lua new file mode 100644 index 0000000..fef6cf2 --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/keyreleased.lua @@ -0,0 +1,33 @@ +game.keyreleased = function(character, key, scancode) + if scancode == button.a then + character.actionA = false + end + + if scancode == button.left then + character.actionLeft = false + end + + if scancode == button.right then + character.actionRight = false + end + + if scancode == button.up then + character.actionUp = false + end + + if scancode == button.down then + character.actionDown = false + end + + if scancode == button.b then + character.actionB = false + end + + if scancode == button.a then + character.actionA = false + + if character.jump.velocity ~= 0 then + character.jump.limitButtonJump = true + end + end +end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/motion.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/motion.lua new file mode 100644 index 0000000..7fb8fb0 --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/motion.lua @@ -0,0 +1,40 @@ +require 'scripts.game.animation' +require 'scripts.game.jump' +require 'scripts.game.stand' +require 'scripts.game.walk_left' +require 'scripts.game.walk_right' +require 'scripts.game.walk_up' +require 'scripts.game.walk_down' + +game.motion = function(metaSprites, character, dt) + game.animation(character.stand, dt) + metaSprites.quad = character.stand[character.stand.currentFrame] + + if character.jump.higher > 0 and character.actionA == true then + game.jump(metaSprites, character, dt) + end + + if character.actionLeft == true and character.actionRight == false then + game.walkLeft(metaSprites, character, dt) + end + + if character.actionRight == true and character.actionLeft == false then + game.walkRight(metaSprites, character, dt) + end + + if character.actionLeft == true and character.actionRight == true then + game.stand(metaSprites, character, dt) + end + + if character.actionUp == true and character.actionDown == false then + game.walkUp(metaSprites, character, dt) + end + + if character.actionDown == true and character.actionUp == false then + game.walkDown(metaSprites, character, dt) + end + + if character.actionUp == true and character.actionDown == true then + game.stand(metaSprites, character, dt) + end +end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/stand.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/stand.lua new file mode 100644 index 0000000..3c31d68 --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/stand.lua @@ -0,0 +1,4 @@ +game.stand = function(metaSprites, character, dt) + game.animation(character.stand, dt) + metaSprites.quad = character.stand[character.stand.currentFrame] +end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_down.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_down.lua new file mode 100644 index 0000000..26d8103 --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_down.lua @@ -0,0 +1,6 @@ +game.walkDown = function(metaSprites, character, dt) + character.position.y = character.position.y + (character.velocity * dt) + character.jump.ground = character.position.y + game.animation(character.walk, dt) + metaSprites.quad = character.walk[character.walk.currentFrame] +end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_left.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_left.lua new file mode 100644 index 0000000..9588f9c --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_left.lua @@ -0,0 +1,6 @@ +game.walkLeft = function(metaSprites, character, dt) + character.position.x = character.position.x - (character.velocity * dt) + game.animation(character.walk, dt) + metaSprites.quad = character.walk[character.walk.currentFrame] + character.scale.x = -1 +end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_right.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_right.lua new file mode 100644 index 0000000..38ba327 --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_right.lua @@ -0,0 +1,6 @@ +game.walkRight = function(metaSprites, character, dt) + character.position.x = character.position.x + (character.velocity * dt) + game.animation(character.walk, dt) + metaSprites.quad = character.walk[character.walk.currentFrame] + character.scale.x = 1 +end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_up.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_up.lua new file mode 100644 index 0000000..f85913c --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_up.lua @@ -0,0 +1,6 @@ +game.walkUp = function(metaSprites, character, dt) + character.position.y = character.position.y - (character.velocity * dt) + character.jump.ground = character.position.y + game.animation(character.walk, dt) + metaSprites.quad = character.walk[character.walk.currentFrame] +end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/keypressed/default.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/keypressed/default.lua index ccf4d3b..f61d64e 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/keypressed/default.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/keypressed/default.lua @@ -1,29 +1,5 @@ -main.keypressed = function(key, scancode, isrepeat) - isrepeat = true - - if scancode == button.quit then - love.event.quit() - end - - if scancode == button.a then - character.bola.actionA = true - character.bola.actionDown = false - character.bola.actionUp = false - end - - if scancode == button.left then - character.bola.actionLeft = true - end +require 'scripts.game.keypressed' - if scancode == button.right then - character.bola.actionRight = true - end - - if scancode == button.up and character.bola.jump.isJumping == false then - character.bola.actionUp = true - end - - if scancode == button.down and character.bola.jump.isJumping == false then - character.bola.actionDown = true - end +main.keypressed = function(key, scancode, isrepeat) + game.keypressed(character.bola, key, scancode, isrepeat) end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/keyreleased/default.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/keyreleased/default.lua index fa3bf6a..694f81d 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/keyreleased/default.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/keyreleased/default.lua @@ -1,33 +1,5 @@ -main.keyreleased = function(key, scancode) - if scancode == button.a then - character.bola.actionA = false - end - - if scancode == button.left then - character.bola.actionLeft = false - end - - if scancode == button.right then - character.bola.actionRight = false - end - - if scancode == button.up then - character.bola.actionUp = false - end +require 'scripts.game.keyreleased' - if scancode == button.down then - character.bola.actionDown = false - end - - if scancode == button.b then - character.bola.actionB = false - end - - if scancode == button.a then - character.bola.actionA = false - - if character.bola.jump.velocity ~= 0 then - character.bola.jump.limitButtonJump = true - end - end +main.keyreleased = function(key, scancode) + game.keyreleased(character.bola, key, scancode) end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/default.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/default.lua index f4c19d3..92e5502 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/default.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/default.lua @@ -1,3 +1,11 @@ +require 'scripts.load.fps' +require 'scripts.load.window_profile' +require 'scripts.load.graphics' +require 'scripts.load.window' +require 'scripts.load.button.default' +require 'scripts.load.meta_sprites.default' +require 'scripts.load.character.default' + main.load = function() load.fps() load.windowProfile() diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/default.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/default.lua deleted file mode 100644 index 3e16e2a..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/default.lua +++ /dev/null @@ -1,7 +0,0 @@ -require 'scripts.tables' -require 'scripts.module.game' -require 'scripts.module.load' -require 'scripts.module.keypressed' -require 'scripts.module.keyreleased' -require 'scripts.module.update' -require 'scripts.module.draw' diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/draw.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/draw.lua deleted file mode 100644 index 221825f..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/draw.lua +++ /dev/null @@ -1,4 +0,0 @@ -require 'scripts.draw.default' -require 'scripts.draw.fps' -require 'scripts.draw.scale' -require 'scripts.draw.printFPS' diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/game.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/game.lua deleted file mode 100644 index 7b46ba1..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/game.lua +++ /dev/null @@ -1,2 +0,0 @@ -require 'scripts.game.animation' -require 'scripts.game.draw' diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/keypressed.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/keypressed.lua deleted file mode 100644 index d43466e..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/keypressed.lua +++ /dev/null @@ -1 +0,0 @@ -require 'scripts.keypressed.default' diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/keyreleased.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/keyreleased.lua deleted file mode 100644 index 839c6ff..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/keyreleased.lua +++ /dev/null @@ -1 +0,0 @@ -require 'scripts.keyreleased.default' diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/load.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/load.lua deleted file mode 100644 index f0a78c2..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/load.lua +++ /dev/null @@ -1,8 +0,0 @@ -require 'scripts.load.default' -require 'scripts.load.fps' -require 'scripts.load.window_profile' -require 'scripts.load.graphics' -require 'scripts.load.window' -require 'scripts.load.button.default' -require 'scripts.load.meta_sprites.default' -require 'scripts.load.character.default' diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/update.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/update.lua deleted file mode 100644 index bb5cc39..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/module/update.lua +++ /dev/null @@ -1,11 +0,0 @@ -require 'scripts.update.default' -require 'scripts.update.fps' -require 'scripts.update.motion.default' -require 'scripts.update.motion.jump' -require 'scripts.update.motion.stand' -require 'scripts.update.motion.walk_left' -require 'scripts.update.motion.walk_right' -require 'scripts.update.motion.walk_up' -require 'scripts.update.motion.walk_down' -require 'scripts.update.gravity' -require 'scripts.update.limit' 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 877b60f..de1592f 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,6 +1,11 @@ +require 'scripts.update.fps' +require 'scripts.game.motion' +require 'scripts.update.gravity' +require 'scripts.update.limit' + main.update = function(dt) update.fps() - update.motion(dt) + game.motion(metaSprites.bola, character.bola, dt) update.gravity(dt) update.limit(dt) end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/default.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/default.lua deleted file mode 100644 index d260891..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/default.lua +++ /dev/null @@ -1,32 +0,0 @@ -update.motion = function(dt) - game.animation(character.bola.stand, dt) - metaSprites.bola.quad = character.bola.stand[character.bola.stand.currentFrame] - - if character.bola.jump.higher > 0 and character.bola.actionA == true then - jump(dt) - end - - if character.bola.actionLeft == true and character.bola.actionRight == false then - walkLeft(dt) - end - - if character.bola.actionRight == true and character.bola.actionLeft == false then - walkRight(dt) - end - - if character.bola.actionLeft == true and character.bola.actionRight == true then - stand(dt) - end - - if character.bola.actionUp == true and character.bola.actionDown == false then - walkUp(dt) - end - - if character.bola.actionDown == true and character.bola.actionUp == false then - walkDown(dt) - end - - if character.bola.actionUp == true and character.bola.actionDown == true then - stand(dt) - end -end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/jump.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/jump.lua deleted file mode 100644 index 1005a53..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/jump.lua +++ /dev/null @@ -1,9 +0,0 @@ -function jump(dt) - if character.bola.jump.limitButtonJump == false then - 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) - - -- game.animation(character.bola.jump, dt) - -- metaSprites.bola.quad = character.bola.jump[character.bola.jump.currentFrame] - end -end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/stand.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/stand.lua deleted file mode 100644 index 04010ce..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/stand.lua +++ /dev/null @@ -1,4 +0,0 @@ -function stand(dt) - game.animation(character.bola.stand, dt) - metaSprites.bola.quad = character.bola.stand[character.bola.stand.currentFrame] -end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_down.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_down.lua deleted file mode 100644 index ba393c7..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_down.lua +++ /dev/null @@ -1,6 +0,0 @@ -function walkDown(dt) - character.bola.position.y = character.bola.position.y + (character.bola.velocity * dt) - character.bola.jump.ground = character.bola.position.y - game.animation(character.bola.walk, dt) - metaSprites.bola.quad = character.bola.walk[character.bola.walk.currentFrame] -end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_left.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_left.lua deleted file mode 100644 index 17f31f3..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_left.lua +++ /dev/null @@ -1,6 +0,0 @@ -function walkLeft(dt) - character.bola.position.x = character.bola.position.x - (character.bola.velocity * dt) - game.animation(character.bola.walk, dt) - metaSprites.bola.quad = character.bola.walk[character.bola.walk.currentFrame] - character.bola.scale.x = -1 -end diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_right.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_right.lua deleted file mode 100644 index 712c680..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_right.lua +++ /dev/null @@ -1,7 +0,0 @@ -function walkRight(dt) - character.bola.position.x = character.bola.position.x + (character.bola.velocity * dt) - game.animation(character.bola.walk, dt) - metaSprites.bola.quad = character.bola.walk[character.bola.walk.currentFrame] - character.bola.scale.x = 1 -end - diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_up.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_up.lua deleted file mode 100644 index a8bd29b..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion/walk_up.lua +++ /dev/null @@ -1,6 +0,0 @@ -function walkUp(dt) - character.bola.position.y = character.bola.position.y - (character.bola.velocity * dt) - character.bola.jump.ground = character.bola.position.y - game.animation(character.bola.walk, dt) - metaSprites.bola.quad = character.bola.walk[character.bola.walk.currentFrame] -end |