• Advertisement

Archived

This topic is now archived and is closed to further replies.

Making an object move in a certain angle

This topic is 5287 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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]

Share this post


Link to post
Share on other sites

  • Advertisement