Pastes:99006  Views:1870576 

Languages:

   ASP
   C#
   C++
   HTML
   Java
   PHP
   VB.NET
   Visual Basic 6

more languages available...




3D Engine and Development SDK

 

 

 

 

 

 

Here's the requested code from the pastebin:

Wrap Lines   Use Line Numbers
//get the angle to which we need to turn in order to face our target
float f = (float)Math.Atan2(tPosition.Y - pPosition.Y, tPosition.X - pPosition.X);
 
double r, l;
 
//if our current facing angle, in radians, is greater than
//the angle which we desire to face
if (pPosition.Facing > f)
{
  //we'd have to turn past North if we're turning left
  l = ((2 * Math.PI) - pPosition.Facing) + f;
  //we don't have to turn past North if we're turning right
  r = pPosition.Facing - f;
}
else
{
  //we don't have to turn past North if we're turning left
  l = f - pPosition.Facing;
  //we have to turn past North if we're turning right
  r = pPosition.Facing + ((2 * Math.PI) - f);
}
 
//let's please turn in the direction where we have to spend
//the least amount of time turning
if (l < r)
  turnkey = Post.ArrowKeys.Left;
else
  turnkey = Post.ArrowKeys.Right;
Syntax Highlighting:  



Copyright 2007 - NoMorePasting.com