From da2452f3bdcf5eff1bf1773a17b27a4deb8b8bad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Fabian=20Silva=20Delgado?= Date: Tue, 6 Dec 2016 18:12:40 -0300 Subject: Keep the code more KISS - part 8 --- .../scripts/game/animation.lua | 3 +- .../scripts/game/jump.lua | 9 ----- .../scripts/game/motion.lua | 46 ++++++++++++++++------ .../scripts/game/stand.lua | 4 -- .../scripts/game/walk_down.lua | 6 --- .../scripts/game/walk_left.lua | 6 --- .../scripts/game/walk_right.lua | 6 --- .../scripts/game/walk_up.lua | 6 --- 8 files changed, 35 insertions(+), 51 deletions(-) delete mode 100644 src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/jump.lua delete mode 100644 src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/stand.lua delete mode 100644 src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_down.lua delete mode 100644 src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_left.lua delete mode 100644 src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_right.lua delete mode 100644 src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_up.lua diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/animation.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/animation.lua index 8667ff6..ff5293d 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/animation.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/animation.lua @@ -1,7 +1,8 @@ game.animation = function(character, dt) character.elapsedTime = character.elapsedTime + dt if character.elapsedTime > (1 / character.fps) then ---[[ if character.loop > 0 then +--[[ + if character.loop > 0 then if loopCounter == nil then character.currentFrame = 1 loopCounter = 1 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 deleted file mode 100644 index 1891af5..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/jump.lua +++ /dev/null @@ -1,9 +0,0 @@ -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/motion.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/motion.lua index 7fb8fb0..3efc9c7 100644 --- 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 @@ -1,40 +1,60 @@ 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) + if character.jump.limitButtonJump == false then +--[[ + game.animation(character.jump, dt) + metaSprites.quad = character.jump[character.jump.currentFrame] +]] + + character.jump.higher = character.jump.higher - dt + character.jump.velocity = character.jump.velocity + character.jump.height * (dt / character.jump.higherMax) + end end if character.actionLeft == true and character.actionRight == false then - game.walkLeft(metaSprites, character, dt) + game.animation(character.walk, dt) + metaSprites.quad = character.walk[character.walk.currentFrame] + + character.position.x = character.position.x - (character.velocity * dt) + character.scale.x = -1 end if character.actionRight == true and character.actionLeft == false then - game.walkRight(metaSprites, character, dt) + game.animation(character.walk, dt) + metaSprites.quad = character.walk[character.walk.currentFrame] + + character.position.x = character.position.x + (character.velocity * dt) + character.scale.x = 1 end if character.actionLeft == true and character.actionRight == true then - game.stand(metaSprites, character, dt) + game.animation(character.stand, dt) + metaSprites.quad = character.stand[character.stand.currentFrame] end if character.actionUp == true and character.actionDown == false then - game.walkUp(metaSprites, character, dt) + game.animation(character.walk, dt) + metaSprites.quad = character.walk[character.walk.currentFrame] + + character.position.y = character.position.y - (character.velocity * dt) + character.jump.ground = character.position.y end if character.actionDown == true and character.actionUp == false then - game.walkDown(metaSprites, character, dt) + game.animation(character.walk, dt) + metaSprites.quad = character.walk[character.walk.currentFrame] + + character.position.y = character.position.y + (character.velocity * dt) + character.jump.ground = character.position.y end if character.actionUp == true and character.actionDown == true then - game.stand(metaSprites, character, dt) + game.animation(character.stand, dt) + metaSprites.quad = character.stand[character.stand.currentFrame] 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 deleted file mode 100644 index 3c31d68..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/stand.lua +++ /dev/null @@ -1,4 +0,0 @@ -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 deleted file mode 100644 index 26d8103..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_down.lua +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index 9588f9c..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_left.lua +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index 38ba327..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_right.lua +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index f85913c..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/walk_up.lua +++ /dev/null @@ -1,6 +0,0 @@ -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 -- cgit v1.2.3