diff options
Diffstat (limited to 'src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts')
8 files changed, 88 insertions, 67 deletions
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/animation.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/animation.lua deleted file mode 100644 index ce93300..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/animation.lua +++ /dev/null @@ -1,38 +0,0 @@ -local animationModule = {} - -function animationModule.animation(dt) - frames = { - bola = require 'scripts.bola.frames' - } - - game = { - animation = function(start, fps, frames, loop) - start = start + (fps * dt) - if math.floor(start) > frames then - if loop > 0 then - if loopCounter == nil then - start = 1 - loopCounter = 1 - elseif loopCounter < loop then - start = 1 - loopCounter = loopCounter + 1 - else - start = frames - end - elseif loop == 0 or loop == false then - start = frames - elseif loop == -1 or loop == true then - start = 1 - end - end - return start - end - } - - character.bola.stand.start = game.animation(character.bola.stand.start, character.bola.stand.fps, frames.bola.stand, -1) - quad = { - bola = character.bola.stand[math.floor(character.bola.stand.start)] - } -end - -return animationModule diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/draw.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/draw.lua new file mode 100644 index 0000000..edaad4c --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/draw.lua @@ -0,0 +1,20 @@ +local drawModule = {} + +function drawModule.motion() + game = {} + game.draw = function(metaSprite, quad, character) + love.graphics.draw( + metaSprites.image, + quad, + character.position.x, + character.position.y, + character.orientation, + character.scale.x, + character.scale.y, + character.origin.x, + character.origin.y + ) + end +end + +return drawModule diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/frames.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/frames.lua deleted file mode 100644 index 89fec44..0000000 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/frames.lua +++ /dev/null @@ -1,5 +0,0 @@ -return { - stand = # character.bola.stand, - walk = # character.bola.walk, - jump = # character.bola.jump, -} diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/jump.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/jump.lua index b69224e..73782e9 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/jump.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/jump.lua @@ -1,12 +1,14 @@ return { love.graphics.newQuad(metaSprites.bola.x * 5, metaSprites.bola.y * 2, metaSprites.bola.x, metaSprites.bola.y, metaSprites.bola.image:getDimensions()), - start = 1, - fps = 9, - height = -250, - velocity = 0, - ground = windowProfile.mode.height / 2, - higher = 0.15, - higherMax = 0.15, + currentFrame = 1, + elapsedTime = 0, + fps = 9, + loop = false, + height = -250, + velocity = 0, + ground = windowProfile.mode.height / 2, + higher = 0.15, + higherMax = 0.15, limitButtonJump = false, - isJumping = false, + isJumping = false, } 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 index effd9ce..c681ae2 100644 --- 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 @@ -1,6 +1,10 @@ local motionModule = {} function motionModule.motion(dt) + game.animation(character.bola.stand) + quad = {} + quad.bola = character.bola.stand[character.bola.stand.currentFrame] + if character.bola.jump.higher > 0 and character.bola.actionA == true then jump(dt) end @@ -35,42 +39,42 @@ function jump(dt) 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) - -- character.bola.jump.start = game.animation(character.bola.jump.start, character.bola.jump.fps, frames.bola.jump, 0) - -- quad.bola = character.bola.jump[math.floor(character.bola.jump.start)] + -- game.animation(character.bola.jump) + -- quad.bola = character.bola.jump[character.bola.jump.currentFrame] end end function stand(dt) - character.bola.stand.start = game.animation(character.bola.stand.start, character.bola.stand.fps, frames.bola.stand, -1) - quad.bola = character.bola.stand[math.floor(character.bola.stand.start)] + game.animation(character.bola.stand) + quad.bola = character.bola.stand[character.bola.stand.currentFrame] end function walkLeft(dt) character.bola.position.x = character.bola.position.x - (character.bola.velocity * dt) - character.bola.walk.start = game.animation(character.bola.walk.start, character.bola.walk.fps, frames.bola.walk, -1) - quad.bola = character.bola.walk[math.floor(character.bola.walk.start)] + game.animation(character.bola.walk) + quad.bola = character.bola.walk[character.bola.walk.currentFrame] character.bola.scale.x = -1 end function walkRight(dt) character.bola.position.x = character.bola.position.x + (character.bola.velocity * dt) - character.bola.walk.start = game.animation(character.bola.walk.start, character.bola.walk.fps, frames.bola.walk, -1) - quad.bola = character.bola.walk[math.floor(character.bola.walk.start)] + game.animation(character.bola.walk) + quad.bola = character.bola.walk[character.bola.walk.currentFrame] character.bola.scale.x = 1 end function walkUp(dt) character.bola.position.y = character.bola.position.y - (character.bola.velocity * dt) character.bola.jump.ground = character.bola.position.y - character.bola.walk.start = game.animation(character.bola.walk.start, character.bola.walk.fps, frames.bola.walk, -1) - quad.bola = character.bola.walk[math.floor(character.bola.walk.start)] + game.animation(character.bola.walk) + quad.bola = character.bola.walk[character.bola.walk.currentFrame] end function walkDown(dt) character.bola.position.y = character.bola.position.y + (character.bola.velocity * dt) character.bola.jump.ground = character.bola.position.y - character.bola.walk.start = game.animation(character.bola.walk.start, character.bola.walk.fps, frames.bola.walk, -1) - quad.bola = character.bola.walk[math.floor(character.bola.walk.start)] + game.animation(character.bola.walk) + quad.bola = character.bola.walk[character.bola.walk.currentFrame] end return motionModule diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/stand.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/stand.lua index da31443..8ec58cf 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/stand.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/stand.lua @@ -66,6 +66,8 @@ return { love.graphics.newQuad(metaSprites.bola.x * 6, metaSprites.bola.y * 0, metaSprites.bola.x, metaSprites.bola.y, metaSprites.bola.image:getDimensions()), love.graphics.newQuad(metaSprites.bola.x * 6, metaSprites.bola.y * 0, metaSprites.bola.x, metaSprites.bola.y, metaSprites.bola.image:getDimensions()), love.graphics.newQuad(metaSprites.bola.x * 5, metaSprites.bola.y * 0, metaSprites.bola.x, metaSprites.bola.y, metaSprites.bola.image:getDimensions()), - start = 1, - fps = 9, + currentFrame = 1, + elapsedTime = 0, + fps = 9, + loop = true, } diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/walk.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/walk.lua index 96c9ca3..5ad6282 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/walk.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/walk.lua @@ -7,6 +7,8 @@ return { love.graphics.newQuad(metaSprites.bola.x * 3, metaSprites.bola.y * 1, metaSprites.bola.x, metaSprites.bola.y, metaSprites.bola.image:getDimensions()), love.graphics.newQuad(metaSprites.bola.x * 4, metaSprites.bola.y * 1, metaSprites.bola.x, metaSprites.bola.y, metaSprites.bola.image:getDimensions()), love.graphics.newQuad(metaSprites.bola.x * 3, metaSprites.bola.y * 1, metaSprites.bola.x, metaSprites.bola.y, metaSprites.bola.image:getDimensions()), - start = 1, - fps = 9, + currentFrame = 1, + elapsedTime = 0, + fps = 9, + loop = true, } 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 new file mode 100644 index 0000000..4f6688f --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/animation.lua @@ -0,0 +1,34 @@ +local animationModule = {} + +function animationModule.animation(dt) + game = {} + game.animation = function(metaSprites) + metaSprites.elapsedTime = metaSprites.elapsedTime + dt + if metaSprites.elapsedTime > (1 / metaSprites.fps) then +--[[ if metaSprites.loop > 0 then + if loopCounter == nil then + metaSprites.currentFrame = 1 + loopCounter = 1 + elseif loopCounter < loop then + metaSprites.currentFrame = 1 + loopCounter = loopCounter + 1 + else + metaSprites.currentFrame = # metaSprites + end + elseif metaSprites.loop == 0 or metaSprites.loop == false then + metaSprites.currentFrame = # metaSprites + elseif metaSprites.loop == -1 or metaSprites.loop == true then + metaSprites.currentFrame = 1 + end +]] + if metaSprites.currentFrame < # metaSprites then + metaSprites.currentFrame = metaSprites.currentFrame + 1 + else + metaSprites.currentFrame = 1 + end + metaSprites.elapsedTime = 0 + end + end +end + +return animationModule |