Making an object move in a certain angle
Im using C# with DX9.
I want to try get my sprite to move at an angle of say 30.... how do I go about doing that...
I know it has something to do with SIN and COS, I tried it, but its not working properly...
Anybody got an example?
Thanks,
ED
I'd guess it's cause you pass degrees and not radians to the cos() and sin() funcs.
EDIT: If you still don't get it right...
newpos_x += cos( angle ) * number_of_pixels_to_move;
newpos_y += sin( angle ) * number_of_pixels_to_move;
EIDT #2: I'm a dumbass, didn't realise you used C#... Well, maybe the syntax is wrong but the logis remains the same.
[edited by - Enselic on September 1, 2003 12:49:20 PM]
[edited by - Enselic on September 1, 2003 1:12:41 PM]
EDIT: If you still don't get it right...
newpos_x += cos( angle ) * number_of_pixels_to_move;
newpos_y += sin( angle ) * number_of_pixels_to_move;
EIDT #2: I'm a dumbass, didn't realise you used C#... Well, maybe the syntax is wrong but the logis remains the same.
[edited by - Enselic on September 1, 2003 12:49:20 PM]
[edited by - Enselic on September 1, 2003 1:12:41 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement