From 09e8c21150e01cb674972966e6a9628bf5df0caa Mon Sep 17 00:00:00 2001 From: "coadde [Márcio Alexandre Silva Delgado]" Date: Thu, 24 Nov 2016 01:02:19 -0300 Subject: Add loop in game.animation() --- .../scripts/bola/animation.lua | 28 +++++++++++++++++----- 1 file 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 = { -- cgit v1.2.3-54-g00ecf