//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); }
public void TestChangeVectorDirection() { double xTo1 = 1.0; double yTo1 = 1.0; double xTo2 = 0.0; double yTo2 = 1.0; double xTo3 = 1.0; double yTo3 = 0.0; double xFrom = 0.0; double yFrom = 0.0; VectorMovement testMovement = new VectorMovement(0.0, 1.0); testMovement.SetDirection(xTo1, yTo1, xFrom, yFrom); Assert.AreEqual(45.0, testMovement.Direction); testMovement.SetDirection(xTo2, yTo2, xFrom, yFrom); Assert.AreEqual(90.0, testMovement.Direction); testMovement.SetDirection(xTo3, yTo3, xFrom, yFrom); Assert.AreEqual(0.0, testMovement.Direction); }
public void TestChangeVectorDirection() { double xTo1 = 1.0; double yTo1 = 1.0; double xTo2 = 0.0; double yTo2 = 1.0; double xTo3 = 1.0; double yTo3 = 0.0; double xFrom = 0.0; double yFrom = 0.0; VectorMovement testMovement = new VectorMovement(0.0, 1.0); testMovement.SetDirection(xTo1, yTo1, xFrom, yFrom); Assert.AreEqual(45.0, testMovement.Direction); testMovement.SetDirection(xTo2, yTo2, xFrom, yFrom); Assert.AreEqual(90.0, testMovement.Direction); testMovement.SetDirection(xTo3, yTo3, xFrom, yFrom); Assert.AreEqual(0.0, testMovement.Direction); }
//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); }
/// <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; }
/// <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 TestStepConvertion() { VectorMovement testMovement = new VectorMovement(0.0, 1.0); //confirm inital values Assert.AreEqual(0.0, testMovement.DeltaX); Assert.AreEqual(0.0, testMovement.DeltaY); //confirm upated values testMovement.Step(0, 0); Assert.AreEqual(1.0, testMovement.DeltaX); Assert.AreEqual(0.0, testMovement.DeltaY); }
public void TestStepConvertion() { VectorMovement testMovement = new VectorMovement(0.0, 1.0); //confirm inital values Assert.AreEqual(0.0, testMovement.DeltaX); Assert.AreEqual(0.0, testMovement.DeltaY); //confirm upated values testMovement.Step(0, 0); Assert.AreEqual(1.0, testMovement.DeltaX); Assert.AreEqual(0.0, testMovement.DeltaY); }
public void TestVectorMovement() { Velocity2D testVelosity = new Velocity2D(5.0, 36.86989764584402); Movement testMovement = new VectorMovement(testVelosity); Point2D testPoint = new Point2D(0.0, 0.0); double[] expectedX = new double[] { 4.0, 8.0, 12.0, 16.0, 20.0, 24.0, 28.0, 32.0, 36.0, 40.0 }; double[] expectedY = new double[] { 3.0, 6.0, 9.0, 12.0, 15.0, 18.0, 21.0, 24.0, 27.0, 30.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 TestVectorMovement() { Velocity2D testVelosity = new Velocity2D(5.0, 36.86989764584402); Movement testMovement = new VectorMovement(testVelosity); Point2D testPoint = new Point2D(0.0, 0.0); double[] expectedX = new double[] { 4.0, 8.0, 12.0, 16.0, 20.0, 24.0, 28.0, 32.0, 36.0, 40.0 }; double[] expectedY = new double[] { 3.0, 6.0, 9.0, 12.0, 15.0, 18.0, 21.0, 24.0, 27.0, 30.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 TestVectorMovement() { Movement testMovement = new VectorMovement(0.0, 1.0); testMovement.Step(0, 0); double x = 0; double y = 0; double[] expectedX = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.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(0, 0); 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 TestVectorMovement() { Movement testMovement = new VectorMovement(0.0, 1.0); testMovement.Step(0, 0); double x = 0; double y = 0; double[] expectedX = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.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(0, 0); 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); } }
//constructor /// <summary> /// BulletEntity, class constructor. /// </summary> /// <param name="x">X position of the bullet.</param> /// <param name="y">Y position of the bullet.</param> /// <param name="direction">Movement Direction of the bullet.</param> /// <param name="drawDirection">Draw Direction of the bullet.</param> /// <param name="colour">Colour of the bullet.</param> /// <param name="bulletType">Type of the bullet.</param> public BulletEntity(double x, double y, double direction, double drawDirection, Colours colour, BulletType bulletType) : base(x, y, new HitBox[] { new HitBox(x - (GameResources.GameImage(bulletType + colour.ToString()).Width / 2.0), y - (GameResources.GameImage(bulletType + colour.ToString()).Height / 2), GameResources.GameImage(bulletType + colour.ToString()).Width, GameResources.GameImage(bulletType + colour.ToString()).Height) }, 1, bulletType + colour.ToString()) { _drawDirection = drawDirection; _bulletColour = colour; _bulletType = bulletType; _movement = new VectorMovement(direction, 1.0); switch (bulletType) { case BulletType.Beam: _movement.Delta = 16.0; break; case BulletType.BigStar: _movement.Delta = 4.0; break; case BulletType.Crystal: _movement.Delta = 8.0; break; case BulletType.Dart: _movement.Delta = 8.0; break; case BulletType.HugeSphere: _movement.Delta = 5.0; break; case BulletType.LargeSphere: _movement.Delta = 6.0; break; case BulletType.Palse: _movement.Delta = 8.0; break; case BulletType.Ring: _movement.Delta = 8.0; break; case BulletType.Seed: _movement.Delta = 8.0; break; case BulletType.Shere: _movement.Delta = 7.0; break; case BulletType.SmallRing: _movement.Delta = 8.0; break; case BulletType.SmallSphere: _movement.Delta = 8.0; break; case BulletType.Star: _movement.Delta = 6.0; break; } }
//constructor /// <summary> /// BulletEntity, class constructor. /// </summary> /// <param name="x">X position of the bullet.</param> /// <param name="y">Y position of the bullet.</param> /// <param name="direction">Movement Direction of the bullet.</param> /// <param name="drawDirection">Draw Direction of the bullet.</param> /// <param name="colour">Colour of the bullet.</param> /// <param name="bulletType">Type of the bullet.</param> public BulletEntity(double x, double y, double direction, double drawDirection, Colours colour, BulletType bulletType) : base(x, y, new HitBox[] { new HitBox(x - (GameResources.GameImage(bulletType + colour.ToString()).Width / 2.0), y - (GameResources.GameImage(bulletType + colour.ToString()).Height / 2), GameResources.GameImage(bulletType + colour.ToString()).Width, GameResources.GameImage(bulletType + colour.ToString()).Height) }, 1, bulletType + colour.ToString()) { _drawDirection = drawDirection; _bulletColour = colour; _bulletType = bulletType; _movement = new VectorMovement(direction, 1.0); switch(bulletType) { case BulletType.Beam: _movement.Delta = 16.0; break; case BulletType.BigStar: _movement.Delta = 4.0; break; case BulletType.Crystal: _movement.Delta = 8.0; break; case BulletType.Dart: _movement.Delta = 8.0; break; case BulletType.HugeSphere: _movement.Delta = 5.0; break; case BulletType.LargeSphere: _movement.Delta = 6.0; break; case BulletType.Palse: _movement.Delta = 8.0; break; case BulletType.Ring: _movement.Delta = 8.0; break; case BulletType.Seed: _movement.Delta = 8.0; break; case BulletType.Shere: _movement.Delta = 7.0; break; case BulletType.SmallRing: _movement.Delta = 8.0; break; case BulletType.SmallSphere: _movement.Delta = 8.0; break; case BulletType.Star: _movement.Delta = 6.0; break; } }