|
||
|
GP Mailing List
ATXGPSIG List
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] RE: Turning to face a direction
============================================================ A personal trainer for your email inbox, My Topica's free newsletter management system provides total email conditioning thru archives, organizers, and options. http://click.topica.com/aaabDlbUrGczbU68iFa/register ============================================================ Hi Tom, You can figure out the exact angle that you need to turn using basic trig. if the player is at position (x1, y1) and the destination is (x2, y2) then the appropriate angle is theta = atan((y2 - y1) / (x2 - x1)) then you'll have to convert that from radians into your system of angles ... which is 32nds of a circle right? so that means you go theta = theta / 6.283185307179586476925286766559 * 32 and then you'll have your answer. you might have to adjust it to make it work correctly for your coordinate system. And if that doesn't work, then... I'm sorry :) it's late in the great down under. you might have to recalculate periodically too to make sure that you're going on the best angle to get you to your destination, but you prolly do that every frame anyway so that's alright.. Oh, also, that's assuming that atan = inverse tan. I think it is... Paul Tom Webb wrote: ============================================================ "So many interesting emails. So little time to read them. Thanks to myTopica, I can find what I want, when I want it." So can you. http://click.topica.com/aaabBCbUrGczbU6XN9a/register ============================================================ Hi, I have the code working for turning a ship around and flying manually but what I really want is for my ship to be able to fly on autopilot. So if I give it a destination X and Y it will slowly (1 in 10 module iterations) turn to face the direction and fly there. I have 36 different directions my ship can face and that is all working fine, I am just having a touch of difficulty with the logic. Any ideas? :-) Tom. ------------------------------------------------------------ Join "Hot Sauce" newsletter at: www.pepperbob.com The "best" FREE samples,FREE offers and CONTESTS 3x a week! <A HREF="http://www.pepperbob.com">CLICK HERE</A> to Join! ____________________________________________________________ T O P I C A -- Learn More. Surf Less. Newsletters, Tips and Discussions on Topics You Choose. http://www.topica.com/partner/tag01 ------------------------------------------------------------ Join "The Six Figure Income Safelist" NOW! Absolutely FREE! Plus receive 3 FREE E-Book downloads for subscribing. http://www.topica.com/lists/sfisafelist/ ____________________________________________________________ T O P I C A -- Learn More. Surf Less. Newsletters, Tips and Discussions on Topics You Choose. http://www.topica.com/partner/tag01
|
|