summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcoadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu>2016-12-03 22:46:01 -0300
committercoadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu>2016-12-03 22:46:01 -0300
commit48651499e2aead78023bcd03f0425ba4afa98010 (patch)
treefbd2884079c5148b1dbdee8ff77c1d333b2ea5d4
parent8a7eb73c905d5b9361a6257484834cf9e11b3058 (diff)
Remove update.animation()
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/main.lua3
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/animation.lua27
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/draw.lua1
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/tables.lua2
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/animation.lua30
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/default.lua2
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion.lua16
7 files changed, 39 insertions, 42 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 9eb2259..fc8fc51 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
@@ -1,5 +1,4 @@
-main = {}
-
+require 'scripts.tables'
require 'scripts.load.default'
require 'scripts.keypressed.default'
require 'scripts.keyreleased.default'
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/animation.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/animation.lua
new file mode 100644
index 0000000..8667ff6
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/animation.lua
@@ -0,0 +1,27 @@
+game.animation = function(character, dt)
+ character.elapsedTime = character.elapsedTime + dt
+ if character.elapsedTime > (1 / character.fps) then
+--[[ if character.loop > 0 then
+ if loopCounter == nil then
+ character.currentFrame = 1
+ loopCounter = 1
+ elseif loopCounter < loop then
+ character.currentFrame = 1
+ loopCounter = loopCounter + 1
+ else
+ character.currentFrame = # character
+ end
+ elseif character.loop == 0 or character.loop == false then
+ character.currentFrame = # character
+ elseif character.loop == -1 or character.loop == true then
+ character.currentFrame = 1
+ end
+]]
+ if character.currentFrame < # character then
+ character.currentFrame = character.currentFrame + 1
+ else
+ character.currentFrame = 1
+ end
+ character.elapsedTime = 0
+ end
+end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/draw.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/draw.lua
index edaad4c..615fadd 100644
--- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/draw.lua
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/draw.lua
@@ -1,7 +1,6 @@
local drawModule = {}
function drawModule.motion()
- game = {}
game.draw = function(metaSprite, quad, character)
love.graphics.draw(
metaSprites.image,
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/tables.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/tables.lua
new file mode 100644
index 0000000..44f3d6c
--- /dev/null
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/tables.lua
@@ -0,0 +1,2 @@
+main = {}
+game = {}
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/animation.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/animation.lua
deleted file mode 100644
index bcb32d1..0000000
--- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/animation.lua
+++ /dev/null
@@ -1,30 +0,0 @@
-update.animation = function(dt)
- game = {}
- game.animation = function(metaSprites)
- metaSprites.elapsedTime = metaSprites.elapsedTime + dt
- if metaSprites.elapsedTime > (1 / metaSprites.fps) then
---[[ if metaSprites.loop > 0 then
- if loopCounter == nil then
- metaSprites.currentFrame = 1
- loopCounter = 1
- elseif loopCounter < loop then
- metaSprites.currentFrame = 1
- loopCounter = loopCounter + 1
- else
- metaSprites.currentFrame = # metaSprites
- end
- elseif metaSprites.loop == 0 or metaSprites.loop == false then
- metaSprites.currentFrame = # metaSprites
- elseif metaSprites.loop == -1 or metaSprites.loop == true then
- metaSprites.currentFrame = 1
- end
-]]
- if metaSprites.currentFrame < # metaSprites then
- metaSprites.currentFrame = metaSprites.currentFrame + 1
- else
- metaSprites.currentFrame = 1
- end
- metaSprites.elapsedTime = 0
- end
- end
-end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/default.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/default.lua
index 186ef03..e106f7d 100644
--- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/default.lua
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/default.lua
@@ -1,14 +1,12 @@
update = {}
require 'scripts.update.fps'
-require 'scripts.update.animation'
require 'scripts.update.motion'
require 'scripts.update.gravity'
require 'scripts.update.limit'
main.update = function(dt)
update.fps()
- update.animation(dt)
update.motion(dt)
update.gravity(dt)
update.limit(dt)
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion.lua
index 80e5b50..2eada30 100644
--- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion.lua
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/update/motion.lua
@@ -1,5 +1,7 @@
+require 'scripts.game.animation'
+
update.motion = function(dt)
- game.animation(character.bola.stand)
+ game.animation(character.bola.stand, dt)
quad = {}
quad.bola = character.bola.stand[character.bola.stand.currentFrame]
@@ -37,26 +39,26 @@ function jump(dt)
character.bola.jump.higher = character.bola.jump.higher - dt
character.bola.jump.velocity = character.bola.jump.velocity + character.bola.jump.height * (dt / character.bola.jump.higherMax)
- -- game.animation(character.bola.jump)
+ -- game.animation(character.bola.jump, dt)
-- quad.bola = character.bola.jump[character.bola.jump.currentFrame]
end
end
function stand(dt)
- game.animation(character.bola.stand)
+ game.animation(character.bola.stand, dt)
quad.bola = character.bola.stand[character.bola.stand.currentFrame]
end
function walkLeft(dt)
character.bola.position.x = character.bola.position.x - (character.bola.velocity * dt)
- game.animation(character.bola.walk)
+ game.animation(character.bola.walk, dt)
quad.bola = character.bola.walk[character.bola.walk.currentFrame]
character.bola.scale.x = -1
end
function walkRight(dt)
character.bola.position.x = character.bola.position.x + (character.bola.velocity * dt)
- game.animation(character.bola.walk)
+ game.animation(character.bola.walk, dt)
quad.bola = character.bola.walk[character.bola.walk.currentFrame]
character.bola.scale.x = 1
end
@@ -64,13 +66,13 @@ end
function walkUp(dt)
character.bola.position.y = character.bola.position.y - (character.bola.velocity * dt)
character.bola.jump.ground = character.bola.position.y
- game.animation(character.bola.walk)
+ game.animation(character.bola.walk, dt)
quad.bola = character.bola.walk[character.bola.walk.currentFrame]
end
function walkDown(dt)
character.bola.position.y = character.bola.position.y + (character.bola.velocity * dt)
character.bola.jump.ground = character.bola.position.y
- game.animation(character.bola.walk)
+ game.animation(character.bola.walk, dt)
quad.bola = character.bola.walk[character.bola.walk.currentFrame]
end