61
General / Problem with moving/turning a sprite in cursor direction
« on: November 30, 2011, 10:39:31 pm »
I don't understand this:
Deg to Rad conversion should be something like:
atan2 function returns the angle in radians, and you are adding some strange value to it. Maybe you have reasons to do it, but I can't deduce more from that piece of code.
Also, I suppose that the center of the sprite is on the middle of the image, so you could simply use this:
Hope it'll be helpful, if not, do the code more specific.
Nice idea showing a video
Code: [Select]
...+(45/PI)
Deg to Rad conversion should be something like:
Code: [Select]
(deg * PI) / 180
atan2 function returns the angle in radians, and you are adding some strange value to it. Maybe you have reasons to do it, but I can't deduce more from that piece of code.
Also, I suppose that the center of the sprite is on the middle of the image, so you could simply use this:
Code: [Select]
float dx = App->GetInput().GetMouseX() - playerPos.x;
float dy = App->GetInput().GetMouseY() - playerPos.y;
Hope it'll be helpful, if not, do the code more specific.
Nice idea showing a video