Beispiel #1
0
 public void FromRadiansTest()
 {
     float radians = MathHelper.PiOver2; // TODO: Initialize to an appropriate value
     SpriteRotation expected = new SpriteRotation(90); // TODO: Initialize to an appropriate value
     SpriteRotation actual;
     actual = SpriteRotation.FromRadians(radians);
     Assert.AreEqual(expected, actual);
 }
Beispiel #2
0
 public void FromDegreesTest()
 {
     float degrees = 0F; // TODO: Initialize to an appropriate value
     SpriteRotation expected = new SpriteRotation(); // TODO: Initialize to an appropriate value
     SpriteRotation actual;
     actual = SpriteRotation.FromDegrees(degrees);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Beispiel #3
0
 public void DegreesTest()
 {
     SpriteRotation target = new SpriteRotation(); // TODO: Initialize to an appropriate value
     float expected = 0F; // TODO: Initialize to an appropriate value
     float actual;
     target.Degrees = expected;
     actual = target.Degrees;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Beispiel #4
0
        /// <summary>
        /// Follow the mouse pointer.
        /// </summary>
        /// <remarks>
        /// Uses the InputLib.Mouse.MouseManager.CurrentMouseState.
        /// </remarks>
        /// <param name="initialRotation">The offset rotation to use in adjusting the Sprite's rotation towards the mouse.</param>
        /// <param name="speed">The speed of following.</param>
        public void FollowMouse(SpriteRotation initialRotation, float speed = .1f)
        {
            MouseState mouse  = MouseManager.CurrentMouseState;
            Vector2    target = new Vector2(mouse.X, mouse.Y);

            Vector2 direction    = target - Position;
            float   acceleration = direction.Length() / 10;

            if (direction.LengthSquared() > 1)
            {
                direction.Normalize();

                direction += new Vector2(speed, speed);
                direction *= acceleration;
                Position  += direction;
                Rotation   = SpriteRotation.FromVector(direction, initialRotation);
            }
        }
Beispiel #5
0
 public void SpriteRotationConstructorTest1()
 {
     float value = 0F; // TODO: Initialize to an appropriate value
     AngleType measurementType = new AngleType(); // TODO: Initialize to an appropriate value
     SpriteRotation target = new SpriteRotation(value, measurementType);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
Beispiel #6
0
 public void SpriteRotationConstructorTest0()
 {
     float degrees = 360F; // TODO: Initialize to an appropriate value
     SpriteRotation target = new SpriteRotation(degrees);
     Assert.AreEqual(MathHelper.TwoPi, target.Radians);
     Assert.AreEqual(324F, target.Gradians);
 }
Beispiel #7
0
 public void RadiansTest()
 {
     SpriteRotation target = new SpriteRotation();
     float expected = 0F;
     float actual;
     target.Radians = expected;
     actual = target.Radians;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Beispiel #8
0
 public void op_SubtractionTest1()
 {
     SpriteRotation x = new SpriteRotation(); // TODO: Initialize to an appropriate value
     SpriteRotation y = new SpriteRotation(); // TODO: Initialize to an appropriate value
     SpriteRotation expected = new SpriteRotation(); // TODO: Initialize to an appropriate value
     SpriteRotation actual;
     actual = (x - y);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
 /// <summary>
 /// Creates a new MouseFollowParams.
 /// </summary>
 /// <param name="speed">The speed of mouse following.</param>
 /// <param name="initialRotation">The initial rotation of the Sprite.</param>
 public MouseFollowParams(float speed, SpriteRotation initialRotation)
 {
     MouseFollowSpeed = speed;
     InitialRotation = initialRotation;
 }
Beispiel #10
0
        public void op_GreaterThanOrEqualTest()
        {
            SpriteRotation x = new SpriteRotation(10); // TODO: Initialize to an appropriate value
            SpriteRotation y = new SpriteRotation(10.5f); // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool expected2 = true;
            bool actual2;
            actual2 = (y >= x);

            bool actual;
            actual = (x >= y);
            Assert.AreEqual(expected, actual);
            Assert.AreEqual(expected2, actual2);
        }
Beispiel #11
0
 public void op_AdditionTest()
 {
     SpriteRotation x = new SpriteRotation(90); // TODO: Initialize to an appropriate value
     SpriteRotation y = new SpriteRotation(MathHelper.Pi, AngleType.Radians); // TODO: Initialize to an appropriate value
     SpriteRotation expected = new SpriteRotation(270); // TODO: Initialize to an appropriate value
     SpriteRotation actual;
     actual = (x + y);
     Assert.AreEqual(expected, actual);
 }
 public void SpriteRotationConstructorTest0()
 {
     float degrees = 360F;
     SpriteRotation target = new SpriteRotation(degrees);
     Assert.AreEqual(MathHelper.TwoPi, target.Radians);
     Assert.AreEqual(degrees, target.Degrees);
     Assert.AreEqual(324.0f, target.Gradians, 0.075f);
 }
 public void op_SubtractionTest()
 {
     SpriteRotation x = new SpriteRotation(360); // TODO: Initialize to an appropriate value
     float y = 180F; // TODO: Initialize to an appropriate value
     SpriteRotation expected = new SpriteRotation(180); // TODO: Initialize to an appropriate value
     SpriteRotation actual;
     actual = (x - y);
     Assert.AreEqual(expected.Degrees, actual.Degrees, 0.075f);
 }
        public void op_LessThanOrEqualTest()
        {
            SpriteRotation x = new SpriteRotation(100); // TODO: Initialize to an appropriate value
            SpriteRotation y = new SpriteRotation(100); // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = (x <= y);

            Assert.AreEqual(expected, actual);

            Assert.AreEqual(false, ((x + y) <= y));
        }
Beispiel #15
0
 /// <summary>
 /// Returns a SpriteRotation representing the specified vector.
 /// </summary>
 /// <param name="vector">The vector to convert to a <see cref="SpriteRotation"/>.</param>
 /// <param name="offsetAngle">The initial angle offset.</param>
 /// <returns>A new SpriteRotation representing the specified vector.</returns>
 public static SpriteRotation FromVector(Vector2 vector, SpriteRotation offsetAngle)
 {
     return(new SpriteRotation(vector.ToAngle(offsetAngle.Radians), AngleType.Radians));
 }
Beispiel #16
0
 public void op_LessThanTest()
 {
     SpriteRotation x = new SpriteRotation(); // TODO: Initialize to an appropriate value
     SpriteRotation y = new SpriteRotation(); // TODO: Initialize to an appropriate value
     bool expected = false; // TODO: Initialize to an appropriate value
     bool actual;
     actual = (x < y);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Beispiel #17
0
 public void GradiansTest()
 {
     SpriteRotation target = new SpriteRotation();
     float expected = 323.1F;
     float actual;
     target.Gradians = expected;
     actual = target.Gradians;
     Assert.AreEqual(expected, actual);
     Assert.AreEqual(target.Degrees, 359);
     Assert.AreEqual(target.Radians, MathHelper.TwoPi-MathHelper.ToRadians(1));
 }
 /// <summary>
 /// Creates a new MouseFollowParams.
 /// </summary>
 /// <param name="speed">The speed of mouse following.</param>
 public MouseFollowParams(float speed)
 {
     MouseFollowSpeed = speed;
     InitialRotation = new SpriteRotation();
 }