Jump to content
  • Advertisement

Archived

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

wazoo69

help with moving where I'm pointing

This topic is 6102 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

Hey gang.. Okay simple problem, that I''m sure SOMEONE has seen before. I''ve got a spaceship .bmp. I can load it fine. I can rotate it left and right fine. What I can''t yet seem to do is to actually MOVE it in the direction it''s pointing.. My algorithm for calculating this, is to take the current rotation value (in degrees), convert this to radians. Then use sin(x angle) for the deltax value, and cos(x angle) for the deltay value... However, no matter which way I''m facing, my .bmp just moves UPWARDS.. any ideas?? thanks,

Share this post


Link to post
Share on other sites
Advertisement
that sounds about right (except you should multiply your deltaX and deltaY by the speed)... maybe it isn''t doing what you think it should be doing?

--- krez (krezisback@aol.com)

Share this post


Link to post
Share on other sites
Yeah...the values I''m getting (via debugging output) SEEM normal, but my ship just loves to fly off in a different direction...*argh*

Back to the drawring board I guess...

Share this post


Link to post
Share on other sites
quote:
Original post by wazoo69
My algorithm for calculating this, is to take the current rotation value (in degrees), convert this to radians. Then
use sin(x angle) for the deltax value, and cos(x angle) for
the deltay value...



I''m not sure what coordinate system you are using, but I''d think it would be cos(angle) for delta x and sin(angle) for delta y.

Regardless, I don''t think that is your main problem. If you want to move the ship a distance L, you need to multiply the result of the trigonometric function by L:
dx = L*cos(angle)
dy = L*sin(angle)

Then add the dx and dy to your original x and y respectively.

Share this post


Link to post
Share on other sites
This might just be a typo, but cosine should represent your x value and sine your y and not the other way around.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!