Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //this bit is just for camera fuckery
- dX = -(int)(pl.deltaRight);
- dY = -(int)(pl.deltaUp);
- this.x -= pl.deltaRight;
- this.y -= pl.deltaUp;
- iAng = (float)Math.Atan2((plPos.X + x - 640), (plPos.Y - y)); //forget magic number, this gets angle between two items
- //clamp
- if (iAng < -Math.PI)
- iAng += (float)Math.PI * 2f;
- else if (iAng > Math.PI)
- iAng -= (float)Math.PI*2f;
- //clamp
- if(rot < -Math.PI)
- rot += (float)Math.PI * 2f;
- else if (rot > Math.PI)
- rot -= (float)Math.PI * 2f;
- dRot = rot - iAng; //get needed rotation
- //clamp again
- if (dRot < -Math.PI)
- dRot += 2f * (float)Math.PI;
- else if (dRot > Math.PI)
- dRot -= 2f * (float)Math.PI;
- //we will be between (-PI, PI) now
- //pick a direction based on sign of dRot
- if (dRot > 0.025f)
- rot -= rotSpeed;
- else if (dRot < -0.025f)
- rot += rotSpeed;
- //Just snap into it if small enough
- else rot = iAng;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement