Пример #1
0
        //constructor
        /// <summary>
        /// ItemEntity, class contructor, passes entity data to base.
        /// </summary>
        /// <param name="x">X position of the item</param>
        /// <param name="y">Y position of the item</param>
        /// <param name="itemType">Type of item</param>
        public ItemEntity(double x, double y, ItemType itemType) : base(x, y, new HitBox[] { new HitBox(x - (GameResources.GameImage("Item" + itemType.ToString()).Width / 2.0), y - (GameResources.GameImage("Item" + itemType.ToString()).Height / 2), GameResources.GameImage("Item" + itemType.ToString()).Width, GameResources.GameImage("Item" + itemType.ToString()).Height) }, 1, "Item" + itemType.ToString())
        {
            _itemType = itemType;

            _vectorMovement = new VectorMovement(90.0, 5.0);
            _gravMovement   = new GravitationalMovement(0.0, -3.0, 0.0, 0.1, 0.0, 1.8);
        }
Пример #2
0
        //constructor
        /// <summary>
        /// ItemEntity, class contructor, passes entity data to base.
        /// </summary>
        /// <param name="x">X position of the item</param>
        /// <param name="y">Y position of the item</param>
        /// <param name="itemType">Type of item</param>
        public ItemEntity(double x, double y, ItemType itemType)
            : base(x, y, new HitBox[] { new HitBox(x - (GameResources.GameImage("Item" + itemType.ToString()).Width / 2.0), y - (GameResources.GameImage("Item" + itemType.ToString()).Height / 2), GameResources.GameImage("Item" + itemType.ToString()).Width, GameResources.GameImage("Item" + itemType.ToString()).Height)}, 1, "Item" + itemType.ToString())
        {
            _itemType = itemType;

            _vectorMovement = new VectorMovement(90.0, 5.0);
            _gravMovement = new GravitationalMovement(0.0, -3.0, 0.0, 0.1, 0.0, 1.8);
        }
Пример #3
0
        /// <summary>
        /// ItemEntity Constructor, initalises item.
        /// </summary>
        /// <param name="point"></param>
        /// <param name="itemType"></param>
        public ItemEntity(Point2D point, ItemType itemType) : base(point, InitaliseBounding(point, itemType), 1, "Item" + itemType.ToString())
        {
            _itemType = itemType;

            _movement     = new GravitationalMovement(new Velocity2D(-3.0, 90.0), new Acceleration2D(new Vector2D(0, 0.1), 1.8));
            _flagMovement = new VectorMovement(new Velocity2D(5.0, 90.0));

            _flag = _itemType == UnrealMechanismCS.ItemType.Star;
        }
Пример #4
0
        /// <summary>
        /// ItemEntity Constructor, initalises item.
        /// </summary>
        /// <param name="point"></param>
        /// <param name="itemType"></param>
        public ItemEntity(Point2D point, ItemType itemType)
            : base(point, InitaliseBounding(point, itemType), 1, "Item" + itemType.ToString())
        {
            _itemType = itemType;

            _movement = new GravitationalMovement(new Velocity2D(-3.0, 90.0), new Acceleration2D(new Vector2D(0, 0.1), 1.8));
            _flagMovement = new VectorMovement(new Velocity2D(5.0, 90.0));

            _flag = _itemType == UnrealMechanismCS.ItemType.Star;
        }
        public void TestGravitationalMovement()
        {
            Acceleration2D testAcceleration = new Acceleration2D(new Vector2D(5.0, 0.0), 200.0);
            Velocity2D testVelosity = new Velocity2D(5.0, 36.86989764584402);
            Movement testMovement = new GravitationalMovement(testVelosity, testAcceleration);
            Point2D testPoint = new Point2D(0.0, 0.0);

            double[] expectedX = new double[] { 8.0, 20.0, 36.0, 56.0, 80.0, 108.0, 140.0, 176.0, 216.0, 260.0 };
            double[] expectedY = new double[] { 6.0, 15.0, 27.0, 42.0, 60.0, 81.0, 105.0, 132.0, 162.0, 195.0 };

            for (int i = 0; i < 10; i++)
            {
                testMovement.Step();

                testPoint.X += testMovement.DeltaX;
                testPoint.Y += testMovement.DeltaY;

                Assert.AreEqual(expectedX[i], testPoint.X, "failure with x on iteration " + i);
                Assert.AreEqual(expectedY[i], testPoint.Y, "failure with y on iteration " + i);
            }
        }
        public void TestGravitationalMovement()
        {
            Acceleration2D testAcceleration = new Acceleration2D(new Vector2D(5.0, 0.0), 200.0);
            Velocity2D     testVelosity     = new Velocity2D(5.0, 36.86989764584402);
            Movement       testMovement     = new GravitationalMovement(testVelosity, testAcceleration);
            Point2D        testPoint        = new Point2D(0.0, 0.0);

            double[] expectedX = new double[] { 8.0, 20.0, 36.0, 56.0, 80.0, 108.0, 140.0, 176.0, 216.0, 260.0 };
            double[] expectedY = new double[] { 6.0, 15.0, 27.0, 42.0, 60.0, 81.0, 105.0, 132.0, 162.0, 195.0 };

            for (int i = 0; i < 10; i++)
            {
                testMovement.Step();

                testPoint.X += testMovement.DeltaX;
                testPoint.Y += testMovement.DeltaY;

                Assert.AreEqual(expectedX[i], testPoint.X, "failure with x on iteration " + i);
                Assert.AreEqual(expectedY[i], testPoint.Y, "failure with y on iteration " + i);
            }
        }
Пример #7
0
        public void TestGravitationalMovement()
        {
            //inital delta = 0, acceleration = 1 unit/tick^2, terminal velosity = 10 units/tick
            Movement testMovement = new GravitationalMovement(0.0, 0.0, 1.0, 0.0, 10.0, 0.0);

            testMovement.Step();

            double x = 0;
            double y = 0;

            double[] expectedX = new double[] { 2.0, 5.0, 9.0, 14.0, 20.0, 27.0, 35.0, 44.0, 54.0, 64.0 };
            double[] expectedY = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            for (int i = 0; i < 10; i++)
            {
                testMovement.Step();

                x += testMovement.DeltaX;
                y += testMovement.DeltaY;

                Assert.AreEqual(expectedX[i], x, "failure with x on iteration " + i);
                Assert.AreEqual(expectedY[i], y, "failure with y on iteration " + i);
            }
        }
        public void TestGravitationalMovement()
        {
            //inital delta = 0, acceleration = 1 unit/tick^2, terminal velosity = 10 units/tick
            Movement testMovement = new GravitationalMovement(0.0, 0.0, 1.0, 0.0, 10.0, 0.0);

            testMovement.Step();

            double x = 0;
            double y = 0;

            double[] expectedX = new double[] { 2.0, 5.0, 9.0, 14.0, 20.0, 27.0, 35.0, 44.0, 54.0, 64.0 };
            double[] expectedY = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            for (int i = 0; i < 10; i++)
            {
                testMovement.Step();

                x += testMovement.DeltaX;
                y += testMovement.DeltaY;

                Assert.AreEqual(expectedX[i], x, "failure with x on iteration " + i);
                Assert.AreEqual(expectedY[i], y, "failure with y on iteration " + i);
            }
        }