So my Code for it is
Code: Select all
local player
local direction
function love.load()
FrameDuration = 0.1
FrameTimer = 0
FrameIndex = 1
FramesWalkingDown = {
love.graphics.newImage("going_down_01.png"),
love.graphics.newImage("going_down_02.png"),
love.graphics.newImage("going_down_03.png"),
love.graphics.newImage("going_down_04.png"),
love.graphics.newImage("going_down_05.png"),
love.graphics.newImage("going_down_06.png")
}
FramesWalkingUp = {
love.graphics.newImage("going_up01.png"),
love.graphics.newImage("going_up02.png"),
love.graphics.newImage("going_up03.png"),
love.graphics.newImage("going_up04.png"),
love.graphics.newImage("going_up05.png"),
love.graphics.newImage("going_up06.png")
}
FramesWalkingRight = {
love.graphics.newImage("going_right01.png"),
love.graphics.newImage("going_right02.png"),
love.graphics.newImage("going_right03.png"),
love.graphics.newImage("going_right04.png"),
love.graphics.newImage("going_right05.png"),
love.graphics.newImage("going_right06.png")
}
FramesWalkingLeft = {
love.graphics.newImage("going_left01.png"),
love.graphics.newImage("going_left02.png"),
love.graphics.newImage("going_left03.png"),
love.graphics.newImage("going_left04.png"),
love.graphics.newImage("going_left05.png"),
love.graphics.newImage("going_left06.png")
}
FrameEnabled = {FramesWalkingUp[FrameIndex], FramesWalkingDown[FrameIndex], FramesWalkingRight[FrameIndex], FramesWalkingLeft[FrameIndex]}
player = {}
player.x = 70
player.y = 70
player.image = love.graphics.newImage("standing_down.png" )
end
Down={}
function love.joystickpressed( joystick, button )
Down[button]=true
end
function love.joystickreleased( joystick, button )
Down[button]=nil
end
love.update=function (dt)
FrameTimer = FrameTimer + dt
if FrameTimer >= FrameDuration then
FrameTimer = 0
FrameIndex = FrameIndex + 1
if FrameIndex > #FramesWalkingDown then
FrameIndex = 1
end
if FrameIndex > #FramesWalkingUp then
FrameIndex = 1
end
if FrameIndex > #FramesWalkingLeft then
FrameIndex = 1
end
if FrameIndex > #FramesWalkingRight then
FrameIndex = 1
end
if Down[06] then
player.x = player.x + 1
FramesEnabled = FramesWalkingUp[FrameIndex]
end
if Down[04] then
player.y = player.y + 1
FramesEnabled = FramesWalkingDown[FrameIndex]
end
if Down[02] then
player.x = player.x - 1
FramesEnabled = FramesWalkingRight[FrameIndex]
end
if Down[00] then
player.y = player.y - 1
FrameEnabled = FramesWalkingUp[FrameIndex]
end
end
end
function love.draw()
love.graphics.draw( FrameEnabled, player.x, player.y )
end