diff options
author | coadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu> | 2016-11-24 05:38:07 -0300 |
---|---|---|
committer | coadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu> | 2016-11-24 11:31:56 -0300 |
commit | 6fd92054f1e06ba8d10060ce0e980d0ba8b57ee1 (patch) | |
tree | a960fea580333288d0120b057fdd643c2bbea69a /src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts | |
parent | 7c0b99d56d0f25cd22f9914f0a17fcf581fb945d (diff) |
Minor fix in origin.{crouchDown,standUp}, Add crouchDown/standUp(), replace love.keyboard.isDown to love.keyboard.isScancodeDown and add restart on game.animation()
Diffstat (limited to 'src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts')
3 files changed, 32 insertions, 12 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 index e3c714e..fb7fddd 100644 --- 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 @@ -12,7 +12,12 @@ function animationModule.animation(dt) } game = { - animation = function(start, frames, loop) + animation = function(start, frames, loop, restart) + if restart == true then + start = start - start + 1 + elseif restart == false or restart == nil then + start = start + end if math.floor(start) > frames then if loop > 0 then if loopCounter == nil then @@ -24,9 +29,9 @@ function animationModule.animation(dt) else start = frames end - elseif loop == 0 then + elseif loop == 0 or loop == false then start = frames - elseif loop == -1 or loop == nil then + elseif loop == -1 or loop == true or loop == nil then start = 1 end end @@ -34,11 +39,11 @@ function animationModule.animation(dt) end } - character.bola.stand.start = game.animation(character.bola.stand.start, frames.bola.stand, -1) - character.bola.walk.start = game.animation(character.bola.walk.start, frames.bola.walk, -1) - character.bola.crouchDown.start = game.animation(character.bola.crouchDown.start, frames.bola.crouchDown, 0) - character.bola.crouch.start = game.animation(character.bola.crouch.start, frames.bola.crouch, -1) - character.bola.standUp.start = game.animation(character.bola.standUp.start, frames.bola.standUp, 0) + character.bola.stand.start = game.animation(character.bola.stand.start, frames.bola.stand, -1, false) + character.bola.walk.start = game.animation(character.bola.walk.start, frames.bola.walk, -1, false) + character.bola.crouchDown.start = game.animation(character.bola.crouchDown.start, frames.bola.crouchDown, 0, false) + character.bola.crouch.start = game.animation(character.bola.crouch.start, frames.bola.crouch, -1, false) + character.bola.standUp.start = game.animation(character.bola.standUp.start, frames.bola.standUp, 0, false) transform = { bola = { 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 08cc791..64bc1c7 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 @@ -3,9 +3,9 @@ local motionModule = {} function motionModule.motion(dt) if love.keyboard.isDown(button.left) then left(dt) - elseif love.keyboard.isDown(button.right) then + elseif love.keyboard.isScancodeDown(button.right) then right(dt) - elseif love.keyboard.isDown(button.down) then + elseif love.keyboard.isScancodeDown(button.down) then crouch(dt) else stand(dt) @@ -42,6 +42,14 @@ function right(dt) character.bola.scale.x = 1 end +function crouchDown(dt) + character.bola.acceleration = 0 + transform.bola.origin.y = character.bola.origin.crouchDown.y[math.floor(character.bola.crouchDown.start)] + quad = { + bola = character.bola.crouchDown[math.floor(character.bola.crouchDown.start)] + } +end + function crouch(dt) character.bola.acceleration = 0 transform.bola.origin.y = character.bola.origin.crouch.y[math.floor(character.bola.crouch.start)] @@ -50,6 +58,13 @@ function crouch(dt) } end +function standUp(dt) + character.bola.acceleration = 0 + quad = { + bola = character.bola.standUp[math.floor(character.bola.standUp.start)] + } +end + function stand(dt) character.bola.acceleration = 0 quad = { diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/origin.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/origin.lua index edfa741..fa9e079 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/origin.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/origin.lua @@ -3,7 +3,7 @@ return { y = metaSprites.bola.y / 2, crouchDown = { y = { - metaSprites.bola.x / 2, + metaSprites.bola.y / 2, (metaSprites.bola.y / 2) - (metaSprites.bola.y / 4), (metaSprites.bola.y / 2) - (metaSprites.bola.y / 2), }, @@ -17,7 +17,7 @@ return { y = { (metaSprites.bola.y / 2) - (metaSprites.bola.y / 2), (metaSprites.bola.y / 2) - (metaSprites.bola.y / 4), - metaSprites.bola.x / 2, + metaSprites.bola.y / 2, }, }, } |