Code: Select all
function love.draw()
love.graphics.draw(turtle, turtlex, turtley, angletomouse, .1, .1)
--More code
end
For whatever reason, the image is rotated by a corner, not the center of the image causing the image to look strange when rotating up close.
Here's the full script(This is a testing script so the variables won't make much sense with the pictures and such)
Code: Select all
function love.load()
--Set a few basic stuff--
love.graphics.setBackgroundColor(50,50,50)
--Define a load of variables--
turtle = love.graphics.newImage("BLACK-MAGE.jpg")
turtlex = 50
turtley = 50
movespeed = 500
--Background music--
end
function love.update(dt)
--Sets mouse variables--
mousex = love.mouse.getX()
mousey = love.mouse.getY()
angletomouse = math.atan2(turtley-mousey,turtlex-mousex)
--Arrow keys--
if love.keyboard.isDown("right") then
turtlex = turtlex + (movespeed * dt)
elseif love.keyboard.isDown("left") then
turtlex = turtlex - (movespeed * dt)
end
if love.keyboard.isDown("down") then
turtley = turtley + (movespeed * dt)
elseif love.keyboard.isDown("up") then
turtley = turtley - (movespeed * dt)
end
--ASWD keys--
if love.keyboard.isDown("d") then
turtlex = turtlex + (movespeed * dt)
elseif love.keyboard.isDown("a") then
turtlex = turtlex - (movespeed * dt)
end
if love.keyboard.isDown("s") then
turtley = turtley + (movespeed * dt)
elseif love.keyboard.isDown("w") then
turtley = turtley - (movespeed * dt)
end
--Quit the game with esc--
if love.keyboard.isDown("escape") then
love.event.quit()
end
end
function love.draw()
--Draw the turtle--
love.graphics.draw(turtle, turtlex, turtley, angletomouse, .1, .1)
love.graphics.print(angletomouse, 250, 0)
--Redefine the player variable--
player = {xaxis=turtlex, yaxis=turtley, width=turtle:getWidth(), height=turtle:getHeight()}
love.graphics.setColor(255, 255, 255)
end