summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcoadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu>2016-11-24 01:02:19 -0300
committercoadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu>2016-11-24 15:42:39 -0300
commit4276916fbacaf53522c1cfc178a57b63504646a8 (patch)
tree1638f693757015553ef90eecdcb76cb25f594d4a
parentf782a1019c2882101fd560890ede70816e2852b5 (diff)
Add loop in game.animation()
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/animation.lua28
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 = {