diff options
author | coadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu> | 2016-11-24 01:02:19 -0300 |
---|---|---|
committer | coadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu> | 2016-11-24 01:02:19 -0300 |
commit | 09e8c21150e01cb674972966e6a9628bf5df0caa (patch) | |
tree | 959dc4bc8c94863863656e3ad6566c1620c1a8ca /src | |
parent | f26f91ba08bcc13fbb0c4c92a882f7bd95fee84d (diff) |
Add loop in game.animation()
Diffstat (limited to 'src')
-rw-r--r-- | src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/animation.lua | 28 |
1 files changed, 22 insertions, 6 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 a370744..0986487 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 @@ -1,24 +1,40 @@ local animationModule = {} function animationModule.animation(dt) - character.bola.stand.start = character.bola.stand.start + (dt * character.bola.stand.fps) - character.bola.walk.start = character.bola.walk.start + (dt * character.bola.walk.fps) + character.bola.stand.start = character.bola.stand.start + (dt * character.bola.stand.fps) + character.bola.walk.start = character.bola.walk.start + (dt * character.bola.walk.fps) +-- character.bola.crouch.start = character.bola.crouch.start + (dt * character.bola.crouch.fps) frames = { bola = require 'scripts.bola.frames' } game = { - animation = function(start, frames) + animation = function(start, frames, loop) if math.floor(start) > frames then - start = 1 + if loop > 0 then + if loopNumber == nil then + start = 1 + loopNumber = 1 + elseif loopNumber < loop then + start = 1 + loopNumber = loopNumber + 1 + else + start = frames + end + elseif loop == 0 then + start = frames + elseif loop == -1 or loop == nil then + start = 1 + end end return start end } - character.bola.stand.start = game.animation(character.bola.stand.start, frames.bola.stand) - character.bola.walk.start = game.animation(character.bola.walk.start, frames.bola.walk) + 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.crouch.start = game.animation(character.bola.crouch.start, frames.bola.crouch, -1) transform = { bola = { |