/// <summary> /// ProcessMovement Method, steps items through their movement patterns /// </summary> public override void ProcessMovement() { switch (_flag) { case true: _flagMovement.Step(); _flagMovement.SetDirection(GameObjects.Player.Position, this.Position); X += _flagMovement.DeltaX; Y += _flagMovement.DeltaY; foreach (Bounding hitBox in Hitboxes) { hitBox.Offset(_flagMovement.Delta); } break; case false: _movement.Step(); X += _movement.DeltaX; Y += _movement.DeltaY; foreach (Bounding hitBox in Hitboxes) { hitBox.Offset(_movement.Delta); } break; } }
/// <summary> /// ProcessMovement, overide method, determines item movement. /// </summary> public override void ProcessMovement() { if (_itemType == ItemType.Star) { _vectorMovement.Step(); _vectorMovement.SetDirection(GameObjects.Player.X, GameObjects.Player.Y, X, Y); X += _vectorMovement.DeltaX; Y += _vectorMovement.DeltaY; foreach (HitBox hitBox in HitBoxes) { hitBox.X += _vectorMovement.DeltaX; hitBox.Y += _vectorMovement.DeltaY; } } else { _gravMovement.Step(); X += _gravMovement.DeltaX; Y += _gravMovement.DeltaY; foreach (HitBox hitBox in HitBoxes) { hitBox.X += _gravMovement.DeltaX; hitBox.Y += _gravMovement.DeltaY; } } }
/// <summary> /// ProcessMovement, overide method, determines bullet movement. /// </summary> public override void ProcessMovement() { _movement.Step(); X += _movement.DeltaX; Y += _movement.DeltaY; foreach (HitBox hitBox in HitBoxes) { hitBox.X += _movement.DeltaX; hitBox.Y += _movement.DeltaY; } }
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); } }
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); } }