summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/animation.lua65
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/motion.lua18
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/jump.lua1
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/stand.lua1
-rw-r--r--src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/walk.lua1
5 files changed, 61 insertions, 25 deletions
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
index ff5293d..e0e98a0 100644
--- 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
@@ -1,28 +1,53 @@
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
+-- frameRestart = 0
+ local frameStart = function()
+ character.currentFrame = 1
+ end
+ local frameCounter = function()
+--[[ if character.restart == true then
+ character.currentFrame = character.currentFrame + 1 - frameRestart
+ else]]
+ character.currentFrame = character.currentFrame + 1
+-- end
+ end
+ local animationStart = function()
+ character.elapsedTime = character.elapsedTime + dt
+ end
+ local animationCounter = function(value)
+ if character.elapsedTime >= (1 / character.fps) then
+ character.elapsedTime = character.elapsedTime - (1 / character.fps)
+ if character.currentFrame == # character then
+ frameStart()
+ if value == 'start' then
+ loopCounter = 1
+ elseif value == 'counter' then
+ loopCounter = loopCounter + 1
+ end
else
- character.currentFrame = # character
+ frameCounter()
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
+ end
+ local animationEnd = function()
+ character.elapsedTime = 0
+ end
+
+ if type(character.loop) == 'number' and character.loop > 0 then
+ if loopCounter == nil then
+ animationStart()
+ animationCounter('start')
+ elseif loopCounter < character.loop then
+ animationStart()
+ animationCounter('counter')
else
- character.currentFrame = 1
+ animationEnd()
+ frameStart()
end
- character.elapsedTime = 0
+ elseif character.loop == 0 or character.loop == false then
+ animationEnd()
+ frameStart()
+ elseif character.loop == -1 or character.loop == true then
+ animationStart()
+ animationCounter()
end
end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/motion.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/motion.lua
index 3efc9c7..c43db43 100644
--- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/motion.lua
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/game/motion.lua
@@ -17,19 +17,23 @@ game.motion = function(metaSprites, character, dt)
end
if character.actionLeft == true and character.actionRight == false then
- game.animation(character.walk, dt)
- metaSprites.quad = character.walk[character.walk.currentFrame]
+ if character.actionUp == false and character.actionDown == false then
+ game.animation(character.walk, dt)
+ metaSprites.quad = character.walk[character.walk.currentFrame]
+ end
character.position.x = character.position.x - (character.velocity * dt)
character.scale.x = -1
end
if character.actionRight == true and character.actionLeft == false then
- game.animation(character.walk, dt)
- metaSprites.quad = character.walk[character.walk.currentFrame]
+ if character.actionUp == false and character.actionDown == false then
+ game.animation(character.walk, dt)
+ metaSprites.quad = character.walk[character.walk.currentFrame]
+ end
character.position.x = character.position.x + (character.velocity * dt)
- character.scale.x = 1
+ character.scale.x = 1
end
if character.actionLeft == true and character.actionRight == true then
@@ -56,5 +60,9 @@ game.motion = function(metaSprites, character, dt)
if character.actionUp == true and character.actionDown == true then
game.animation(character.stand, dt)
metaSprites.quad = character.stand[character.stand.currentFrame]
+ if character.actionLeft == true then
+ end
+ if character.actionRight == true then
+ end
end
end
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/jump.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/jump.lua
index 73782e9..c74d5de 100644
--- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/jump.lua
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/jump.lua
@@ -4,6 +4,7 @@ return {
elapsedTime = 0,
fps = 9,
loop = false,
+ restart = true,
height = -250,
velocity = 0,
ground = windowProfile.mode.height / 2,
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/stand.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/stand.lua
index 8ec58cf..eb5c68a 100644
--- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/stand.lua
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/stand.lua
@@ -70,4 +70,5 @@ return {
elapsedTime = 0,
fps = 9,
loop = true,
+ restart = true,
}
diff --git a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/walk.lua b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/walk.lua
index 5ad6282..df7d396 100644
--- a/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/walk.lua
+++ b/src/gnu_and_bola_-_the_libre_beat_em_up_game/scripts/load/character/bola/walk.lua
@@ -11,4 +11,5 @@ return {
elapsedTime = 0,
fps = 9,
loop = true,
+ restart = true,
}