|
Problems with rotating co-ordinates |
Moonsdescend
Member #4,087
December 2003
|
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? |
ngiacomelli
Member #5,114
October 2004
|
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.
|
Jonatan Hedborg
Member #4,886
July 2004
|
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 =))
|
Moonsdescend
Member #4,087
December 2003
|
Quote: You probably need to rotate 29,3 by whatever the sprite is rotated by.
I think so. |
Jonatan Hedborg
Member #4,886
July 2004
|
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
|
|