Skip to content

Instantly share code, notes, and snippets.

@NietzscheX
Created October 29, 2017 04:50
Show Gist options
  • Save NietzscheX/a799f340662c113c1580cbcfd60952e0 to your computer and use it in GitHub Desktop.
Save NietzscheX/a799f340662c113c1580cbcfd60952e0 to your computer and use it in GitHub Desktop.
function love.load()
sprite = {}
sprite.charactor = love.graphics.newImage([[images/gripe.run_right.png]])
sprite.x = 300
sprite.y = 400
quads = {}
quads.right = {}
quads.left = {}
for j =1,8 do
quads['right'][j] = love.graphics.newQuad((j-1)*32,0,32,32,256,32)
quads['left'][j] = love.graphics.newQuad((j-1)*32,0,32,32,256,32)
--quads['left'][j]:flip(true,false) --removed since 0.9
end
it = 1
max_it = 8
timer = 0.1
end
function Quad:flip(sx,sy)
self.x ,self.y = sy,sx
end
function love.update(dt)
timer = timer + dt
if timer > 0.2 then
timer = 0.1
it = it + 1
if love.keyboard.isDown('right') then
sprite.x = sprite.x + 5
end
if love.keyboard.isDown('left') then
sprite.x = sprite.x - 5
end
if it > max_it then
it = 1
end
end
end
function love.draw()
love.graphics.draw(sprite.charactor,quads.right[it],sprite.x,sprite.y)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment