summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test0/main.lua49
1 files changed, 34 insertions, 15 deletions
diff --git a/test0/main.lua b/test0/main.lua
index 9874bf0..ba8c950 100644
--- a/test0/main.lua
+++ b/test0/main.lua
@@ -55,8 +55,8 @@ function love.load()
y = sprites.bola.y / 2,
},
acceleration = 0,
- speed = 200,
- stand = {
+ speed = 125,
+ stand = {
love.graphics.newQuad(sprites.bola.x * 0, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()),
love.graphics.newQuad(sprites.bola.x * 0, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()),
love.graphics.newQuad(sprites.bola.x * 0, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()),
@@ -127,7 +127,7 @@ function love.load()
start = 1,
fps = 9,
},
- walk = {
+ walk = {
love.graphics.newQuad(sprites.bola.x * 0, sprites.bola.y * 1, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()),
love.graphics.newQuad(sprites.bola.x * 1, sprites.bola.y * 1, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()),
love.graphics.newQuad(sprites.bola.x * 2, sprites.bola.y * 1, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()),
@@ -139,6 +139,18 @@ function love.load()
start = 1,
fps = 9,
},
+ run = {
+ love.graphics.newQuad(sprites.bola.x * 0, sprites.bola.y * 1, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()),
+ love.graphics.newQuad(sprites.bola.x * 1, sprites.bola.y * 1, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()),
+ love.graphics.newQuad(sprites.bola.x * 2, sprites.bola.y * 1, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()),
+ love.graphics.newQuad(sprites.bola.x * 1, sprites.bola.y * 1, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()),
+ love.graphics.newQuad(sprites.bola.x * 0, sprites.bola.y * 1, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()),
+ love.graphics.newQuad(sprites.bola.x * 3, sprites.bola.y * 1, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()),
+ love.graphics.newQuad(sprites.bola.x * 4, sprites.bola.y * 1, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()),
+ love.graphics.newQuad(sprites.bola.x * 3, sprites.bola.y * 1, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()),
+ start = 1,
+ fps = 12,
+ },
crouch = {
love.graphics.newQuad(sprites.bola.x * 2, sprites.bola.y * 2, sprites.bola.x, sprites.bola.y / 2, sprites.bola.image:getDimensions()),
start = 1,
@@ -167,21 +179,24 @@ function love.update(dt)
}
}
- if character.bola.stand.start > frames.bola.stand + 1 then
+ -- experimetal function to replace if statement --
+ game = {
+ animation = function(start, frames)
+ if math.floor(start) > frames then
+ start = 1
+ end
+ return start
+ end
+ }
+
+ if math.floor(character.bola.stand.start) > frames.bola.stand then
character.bola.stand.start = 1
end
- if character.bola.walk.start > frames.bola.walk + 1 then
+ if math.floor(character.bola.walk.start) > frames.bola.walk then
character.bola.walk.start = 1
end
- animation = {
- bola = {
- stand = math.floor(character.bola.stand.start),
- walk = math.floor(character.bola.walk.start),
- }
- }
-
transform = {
bola = {
origin = {
@@ -199,7 +214,8 @@ function love.update(dt)
character.bola.position.x = character.bola.position.x - (character.bola.speed * dt) - 3
end
end
- quad = character.bola.walk[animation.bola.walk]
+ quad = character.bola.walk[math.floor(character.bola.walk.start)]
+-- quad = character.bola.walk[game.animation(character.bola.walk.start, frames.bola.walk)]
character.bola.scale.x = -1
elseif love.keyboard.isDown(button.right) then
character.bola.acceleration = character.bola.acceleration + dt
@@ -210,7 +226,8 @@ function love.update(dt)
character.bola.position.x = character.bola.position.x + (character.bola.speed * dt) + 3
end
end
- quad = character.bola.walk[animation.bola.walk]
+ quad = character.bola.walk[math.floor(character.bola.walk.start)]
+-- quad = character.bola.walk[game.animation(character.bola.walk.start, frames.bola.walk)]
character.bola.scale.x = 1
elseif love.keyboard.isDown(button.down) then
character.bola.acceleration = 0
@@ -218,7 +235,8 @@ function love.update(dt)
quad = character.bola.crouch[1]
else
character.bola.acceleration = 0
- quad = character.bola.stand[animation.bola.stand]
+ quad = character.bola.stand[math.floor(character.bola.stand.start)]
+-- quad = character.bola.stand[game.animation(character.bola.stand.start, frames.bola.stand)]
end
end
@@ -226,6 +244,7 @@ function love.draw()
local currentTime = love.timer.getTime()
if nextTime <= currentTime then
nextTime = currentTime
+ return
end
love.timer.sleep(nextTime - currentTime)