Hi All,
I'm trying to make a sprite rotate according to the mouse position, which I have working, however what I want to do is have a line drawn from a specific position to the mouse cursor.
For example my sprite is 32*32 and the point I want the line to start from is x=29,y=3. The line draws fine if the mouse is directly to the right of the sprite, but once the rotation starts it doesn't line up properly. Basically I want the start of the line to rotate with the sprite.
Any ideas on house this could work?
]]>I'll point you towards this wonderful document: http://pixwiki.bafsoft.com/mags/5/articles/circle/sincos.htm
More specifically, this code snippet:
Where 9 is the length of the line. The rest is pretty self-explanatory. I hope this is what you wanted.
]]>You probably need to rotate 29,3 by whatever the sprite is rotated by.
Taken from some google result...
Angles in doubles (radians) (or fixed, if you want to use allegros functions. Don't use allegros functions btw =))
]]>You probably need to rotate 29,3 by whatever the sprite is rotated by.
I think so.
What I think I need to do is rotate X+29 by angle and Y+3 by angle. This area has never been my strong point
So far I've had no luck with the samples that have been posted. They have caused some interesting effects which I might use later on though
The code that i posted does just that. What effects are you having? If you are using fixed format angles (which are 0-255, while radians are 0-PI*2), that might be the reason.
Post the relevant code and we can look at it
]]>