Here is the code I have
Code: Select all
if love.mouse.isDown(mouse) then
touchx = love.mouse.getX()
touchy = love.mouse.getY()
direction = math.atan2(touchy-(height/2), touchx-(width/2))
angle = direction*180/math.pi
playerx = playerx + math.cos(direction) * dt * speed
playery = playery + math.sin(direction) * dt * speed
end
if love.keyboard.isDown("w") then
playery = playery - dt * speed
end
if love.keyboard.isDown("a") then
playerx = playerx - (speed*dt)
end
if love.keyboard.isDown("s") then
playery = playery + (speed*dt)
end
if love.keyboard.isDown("d") then
playerx = playerx + (speed*dt)
end