Advertisement
Guest User

Untitled

a guest
Jan 31st, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. //this bit is just for camera fuckery
  2. dX = -(int)(pl.deltaRight);
  3. dY = -(int)(pl.deltaUp);
  4.  
  5.  
  6. this.x -= pl.deltaRight;
  7. this.y -= pl.deltaUp;
  8. iAng = (float)Math.Atan2((plPos.X + x - 640), (plPos.Y - y)); //forget magic number, this gets angle between two items
  9.  
  10. //clamp
  11. if (iAng < -Math.PI)
  12.     iAng += (float)Math.PI * 2f;
  13. else if (iAng > Math.PI)
  14.     iAng -= (float)Math.PI*2f;
  15.  
  16. //clamp
  17. if(rot < -Math.PI)
  18.     rot += (float)Math.PI * 2f;
  19. else if (rot > Math.PI)
  20.     rot -= (float)Math.PI * 2f;
  21.  
  22. dRot = rot - iAng; //get needed rotation
  23.  
  24. //clamp again
  25. if (dRot < -Math.PI)
  26.     dRot += 2f * (float)Math.PI;
  27. else if (dRot > Math.PI)
  28.     dRot -= 2f * (float)Math.PI;
  29.  
  30. //we will be between (-PI, PI) now
  31. //pick a direction based on sign of dRot
  32. if (dRot > 0.025f)
  33.     rot -= rotSpeed;
  34. else if (dRot < -0.025f)
  35.     rot += rotSpeed;
  36.  
  37. //Just snap into it if small enough
  38. else rot = iAng;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement