Example #1
0
        public static Vector2 ThumbMovement(Vector2 state)
        {
            float xb = state.X;
            float yb = state.Y;

            Vector2 direction = new Vector2(xb, yb);

            float deadZone = 0.3f;
            if (direction.Length() < deadZone)
            {
                direction = Vector2.Zero;
            }
            else
            {
                direction = direction.GetNormalized() * ((direction.Length() - deadZone) / (1 - deadZone));
            }

            //if (direction.Length() > 0.95f)
            //{
            //    float magnitude = 0.95f;
            //    direction.Normalize();
            //    direction.X = direction.X * magnitude;
            //    direction.Y = direction.Y * magnitude;
            //}
            return direction;
        }
Example #2
0
        public void normalized() {
            var v = new Vector2(3, 4);
            v = v.GetNormalized();

            Assert.Equal(3.0 / 5.0, v.X);
            Assert.Equal(4.0 / 5.0, v.Y);
        }