Example #1
0
 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);
 }
Example #2
0
 public void RenderRotatingRect()
 {
     var rect = new FilledRect(Rectangle.FromCenter(Vector2D.Half, new Size(0.2f)), Color.Orange)
     {
         Rotation = 0
     };
     rect.Add(new SimplePhysics.Data { Gravity = Vector2D.Zero, RotationSpeed = 5 });
     rect.Start<SimplePhysics.Rotate>();
 }
Example #3
0
 public void RotateAdvancesAngleCorrectly()
 {
     var rect = new FilledRect(new Rectangle(ScreenSpace.Current.Viewport.TopLeft, new Size(0.2f)),
         Color.Red);
     rect.Rotation = 0;
     rect.Add(new SimplePhysics.Data { Gravity = Vector2D.Zero, RotationSpeed = 0.1f });
     rect.Start<SimplePhysics.Rotate>();
     AdvanceTimeAndUpdateEntities();
     Assert.Greater(rect.Rotation, 0);
 }