#### Archived

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

# help with moving where I'm pointing

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

## 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 on other sites
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 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 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 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.

1. 1
2. 2
frob
15
3. 3
4. 4
5. 5
Rutin
12

• 12
• 12
• 58
• 14
• 15
• ### Forum Statistics

• Total Topics
632115
• Total Posts
3004197

×