diff options
author | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-11-23 23:03:47 -0300 |
---|---|---|
committer | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-11-23 23:03:47 -0300 |
commit | 06ac50db0f813a2954651600760f6ff30c6fd5d1 (patch) | |
tree | af2d7534985444853b20fc0f5c0f2d0a70ba0a01 /src | |
parent | 5a76611deb0b74cba12a108d1786d0e49b36733b (diff) |
Modularize bola animation (bolaAnimation) in scripts/bola/animation.lua
Diffstat (limited to 'src')
-rw-r--r-- | src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua | 27 | ||||
-rw-r--r-- | src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/animation.lua | 29 |
2 files changed, 32 insertions, 24 deletions
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua index e47c5dd..9da062d 100644 --- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua @@ -26,7 +26,8 @@ function love.load() bola = require 'scripts.bola.bola' } - bolaMotion= require 'scripts.bola.motion' + bolaAnimation = require 'scripts.bola.animation' + bolaMotion = require 'scripts.bola.motion' end function love.keypressed(key) @@ -38,29 +39,7 @@ end function love.update(dt) nextTime = nextTime + (1 / 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) - - frames = { - bola = require 'scripts.bola.frames' - } - - game = { - animation = function(start, frames) - if math.floor(start) > frames then - start = 1 - 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) - - transform = { - bola = require 'scripts.bola.transform' - } - + bolaAnimation.animation(dt) bolaMotion.motion(dt) end 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 new file mode 100644 index 0000000..bd1e8de --- /dev/null +++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/bola/animation.lua @@ -0,0 +1,29 @@ +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) + + frames = { + bola = require 'scripts.bola.frames' + } + + game = { + animation = function(start, frames) + if math.floor(start) > frames then + start = 1 + 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) + + transform = { + bola = require 'scripts.bola.transform' + } + +end + +return animationModule |