All pastes #1170824 Raw Edit

Miscellany

public text v1 · immutable
#1170824 ·published 2008-08-14 02:33 UTC
rendered paste body
        public void Update(Vector3 pointToFace)
        {
            float currentRotation = (float)Math.Atan2(this.Sprite.YVelocity, this.Sprite.XVelocity);
            decimal r = (decimal)TurnToFace(this.Sprite.Velocity, pointToFace, currentRotation, this.TurningSpeed);

            Vector3 v;
            v.X = Math.Cos(r) * this.Sprite.XVelocity - Math.Sin(r) * this.Sprite.YVelocity;
            v.Y = Math.Cos(r) * this.Sprite.YAcceleration + Math.Sin(r) * this.Sprite.XAcceleration;
            this.Sprite.Velocity = v;
            this.Sprite.RotationZ = (float)Math.Atan2(this.Sprite.YVelocity, this.Sprite.XVelocity);
        }