Just started playing around with love to see how it all works and im quiet impressed.
Though looking through the wiki and forum I cant seem to find my answer.
Im trying to animate the character when he walks. I have 8 images per direction .
I looked at AnAL but i dont think it will do what i want.
Code: Select all
function love.load()
player = love.graphics.newImage("images/soldier/walking s0000.bmp")
player_x = 100
player_y = 50
player_speed = 100
i = 0
love.graphics.setBackgroundColor(110,80,52)
lastkey = "nothing"
keynow = "nothing"
end
function love.keypressed(key)
keynow = key
end
function love.keyreleased(key)
lastkey = key
end
function love.update(dt)
key_Right = love.keyboard.isDown("right")
key_Left = love.keyboard.isDown("left")
key_Down = love.keyboard.isDown("down")
key_Up = love.keyboard.isDown("up")
if key_Right then
player = love.graphics.newImage("images/soldier/walking e0000.bmp")
player_x = player_x + (player_speed * dt)
elseif key_Left then
player = love.graphics.newImage("images/soldier/walking w0000.bmp")
player_x = player_x - (player_speed * dt)
elseif key_Up then
player = love.graphics.newImage("images/soldier/walking n0000.bmp")
player_y = player_y - (player_speed * dt)
elseif key_Down then
player = love.graphics.newImage("images/soldier/walking s0000.bmp")
player_y = player_y + (player_speed * dt)
end
if love.keyboard.isDown( "escape" ) then
love.event.push( "q" )
end
end
function love.draw()
love.graphics.draw(player, player_x, player_y)
love.graphics.print("FPS: "..love.timer.getFPS(), 10, 20)
love.graphics.print(i, 10,40)
love.graphics.print("key Now: " .. keynow, 10, 60)
love.graphics.print("Last key: " .. lastkey, 10, 80)
end