I am trying to make this image of the letter L basically rotate its angle by where the mouse position of Y is. The way I have it setup makes it rotate uncontrollably fast and also rotates around the back of the L when I want it to rotate up/down from the top of the L. I do have source to show you what it does..How could I fix this so the image can rotate up/down with the mouse? also code below too.
function love.load()
love.graphics.setBackgroundColor(0,200,200)
x = love.graphics.getWidth() / 2
y = love.graphics.getHeight() / 2
letter = love.graphics.newImage("letter.png")
end
The fourth parameter of love.graphics.draw() is the orientation and needs to be given in radians.
You are giving it one half of a coordinate on the screen, the Y part. Which is a distance measured in pixels. You're not giving it the correct value. https://www.love2d.org/wiki/love.graphics.draw
You need to:
- calculate the distance between the letter's position and the mouse position
- calculate the angle between this line and the horizontal
You can achieve this using basic trigonometry.
Do you want the letter to rotate instantly according to mouse movement? Or do you want the letter to rotate incrementally with a certain speed (so that, if the mouse moves really fast, the letter will lag behind)?
nfey wrote:Or do you want the letter to rotate incrementally with a certain speed (so that, if the mouse moves really fast, the letter will lag behind)?
Yes I want to do that but how would I code that? It is what I am asking because I don't know honestly how that would work.