SimplePhysicsTests BounceOffScreenEdge Method Delta Engine Documentation

Namespace: DeltaEngine.Rendering2D.Tests
Assembly: DeltaEngine.Rendering2D.Tests (in DeltaEngine.Rendering2D.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public void BounceOffScreenEdge()
Examples

[Test]
public void BounceOffScreenEdge()
{
    var rect =
        new FilledRect(new Rectangle(ScreenSpace.Current.Viewport.TopLeft, new Size(0.2f)),
            Color.Red);
    rect.Add(new SimplePhysics.Data
    {
        Gravity = Vector2D.Zero,
        Velocity = new Vector2D(-0.1f, 0.0f)
    });
    rect.Start<SimplePhysics.Move>();
    rect.Start<SimplePhysics.BounceIfAtScreenEdge>();
    var collided = false;
    rect.Get<SimplePhysics.Data>().Bounced += () => collided = true;
    AdvanceTimeAndUpdateEntities();
    Assert.IsTrue(collided);
    Assert.AreEqual(0.1f, rect.Get<SimplePhysics.Data>().Velocity.X);
}
See Also