diff options
author | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-11-21 17:40:37 -0300 |
---|---|---|
committer | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-11-21 17:41:49 -0300 |
commit | ed9476d0af54bfd679eeb13fe8bd46afbc85bbf6 (patch) | |
tree | 57db03204df40e558ad2c3043520a7ec6873d561 | |
parent | 045f89441fb8ee460c3dedcca45ed7f0edf3e2fd (diff) |
Add initial walking animation
-rw-r--r-- | test0/main.lua | 102 |
1 files changed, 96 insertions, 6 deletions
diff --git a/test0/main.lua b/test0/main.lua index 0192498..206662f 100644 --- a/test0/main.lua +++ b/test0/main.lua @@ -7,7 +7,7 @@ function love.load() width = 256, height = 240, }, - title = "GNU & Bola - The libre beat 'em up game", + title = "GNU & Bola - The libre beat'em up game", } love.graphics.setBackgroundColor(0, 232, 216) @@ -40,6 +40,11 @@ function love.load() x = windowProfile.mode.width / 2, y = windowProfile.mode.height / 2, }, + orientation = 0, + scale = { + x = 1, + y = 1, + }, origin = { x = sprites.bola.x / 2, y = sprites.bola.y / 2, @@ -48,21 +53,73 @@ function love.load() speed = 200, spriteStand = { 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()), + 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()), + 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()), + 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()), love.graphics.newQuad(sprites.bola.x * 1, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), love.graphics.newQuad(sprites.bola.x * 2, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), love.graphics.newQuad(sprites.bola.x * 1, 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()), + 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()), + 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()), + 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()), + 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 * 3, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), love.graphics.newQuad(sprites.bola.x * 4, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 4, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 4, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 4, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 4, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 4, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 4, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 4, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 4, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 4, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 4, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 4, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), love.graphics.newQuad(sprites.bola.x * 3, 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()), + 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()), + 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()), + 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()), + 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 * 5, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), love.graphics.newQuad(sprites.bola.x * 6, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 6, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 6, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 6, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 6, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 6, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 6, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 6, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 6, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 6, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 6, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 6, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), + love.graphics.newQuad(sprites.bola.x * 6, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), love.graphics.newQuad(sprites.bola.x * 5, 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 * 7, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), - love.graphics.newQuad(sprites.bola.x * 8, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), - love.graphics.newQuad(sprites.bola.x * 7, sprites.bola.y * 0, sprites.bola.x, sprites.bola.y, sprites.bola.image:getDimensions()), start = 1, fps = 9, }, @@ -115,6 +172,29 @@ function love.update(dt) spriteWalk = math.floor(character.bola.spriteWalk.start), } } + + if love.keyboard.isDown(button.left) then + character.bola.acceleration = character.bola.acceleration + dt + if character.bola.acceleration < 3 then + character.bola.position.x = character.bola.position.x - (character.bola.speed * dt) - character.bola.acceleration + else + character.bola.position.x = character.bola.position.x - (character.bola.speed * dt) - 3 + end + quad = character.bola.spriteWalk[animation.bola.spriteWalk] + character.bola.scale.x = -1 + elseif love.keyboard.isDown(button.right) then + character.bola.acceleration = character.bola.acceleration + dt + if character.bola.acceleration < 3 then + character.bola.position.x = character.bola.position.x + (character.bola.speed * dt) + character.bola.acceleration + else + character.bola.position.x = character.bola.position.x + (character.bola.speed * dt) + 3 + end + quad = character.bola.spriteWalk[animation.bola.spriteWalk] + character.bola.scale.x = 1 + else + character.bola.acceleration = 0 + quad = character.bola.spriteStand[animation.bola.spriteStand] + end end function love.draw() @@ -124,5 +204,15 @@ function love.draw() end love.timer.sleep(nextTime - currentTime) love.graphics.print('FPS: ' .. love.timer.getFPS(), 0, 0) - love.graphics.draw(sprites.bola.image, character.bola.spriteWalk[animation.bola.spriteWalk], character.bola.position.x, character.bola.position.y, 0, 1, 1, character.bola.origin.x, character.bola.origin.y) + love.graphics.draw( + sprites.bola.image, + quad, + character.bola.position.x, + character.bola.position.y, + character.bola.orientation, + character.bola.scale.x, + character.bola.scale.y, + character.bola.origin.x, + character.bola.origin.y + ) end |