예제 #1
0
        public void RenderSpinningRectangleAttachedToMouse()
        {
            var rect = new FilledRect(new Rectangle(0.5f, 0.5f, 0.4f, 0.1f), Color.Blue);

            rect.Start <Spin>();
            new Command(point => rect.DrawArea = Rectangle.FromCenter(point, rect.DrawArea.Size)).Add(
                new MouseMovementTrigger());
        }
예제 #2
0
 public void ControlRectanglesWithMouseAndWhenTheyCollideTheyChangeColor()
 {
     var r1 = new FilledRect(new Rectangle(0.2f, 0.2f, 0.1f, 0.1f), Color.Red) { Rotation = 45 };
     var r2 = new FilledRect(new Rectangle(0.6f, 0.6f, 0.1f, 0.2f), Color.Red) { Rotation = 70 };
     r1.Start<CollidingChangesColor>();
     r2.Start<CollidingChangesColor>();
     new Command(point => r1.Center = point).Add(new MouseButtonTrigger(MouseButton.Left,
         State.Pressed));
     new Command(point => r2.Center = point).Add(new MouseButtonTrigger(MouseButton.Right,
         State.Pressed));
 }
        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);
        }
        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>();
        }
        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);
        }
예제 #6
0
        public void ControlRectanglesWithMouseAndWhenTheyCollideTheyChangeColor()
        {
            var r1 = new FilledRect(new Rectangle(0.2f, 0.2f, 0.1f, 0.1f), Color.Red)
            {
                Rotation = 45
            };
            var r2 = new FilledRect(new Rectangle(0.6f, 0.6f, 0.1f, 0.2f), Color.Red)
            {
                Rotation = 70
            };

            r1.Start <CollidingChangesColor>();
            r2.Start <CollidingChangesColor>();
            new Command(point => r1.Center = point).Add(new MouseButtonTrigger(MouseButton.Left,
                                                                               State.Pressed));
            new Command(point => r2.Center = point).Add(new MouseButtonTrigger(MouseButton.Right,
                                                                               State.Pressed));
        }
예제 #7
0
 public void RenderSpinningRectangleAttachedToMouse()
 {
     var rect = new FilledRect(new Rectangle(0.5f, 0.5f, 0.4f, 0.1f), Color.Blue);
     rect.Start<Spin>();
     new Command(point => rect.DrawArea = Rectangle.FromCenter(point, rect.DrawArea.Size)).Add(
         new MouseMovementTrigger());
 }
예제 #8
0
 public void RenderGrowingRotatingRectangle()
 {
     var rect = new FilledRect(new Rectangle(0.3f, 0.3f, 0.1f, 0.1f), Color.Red);
     rect.Start<Grow>();
 }
예제 #9
0
        public void RenderGrowingRotatingRectangle()
        {
            var rect = new FilledRect(new Rectangle(0.3f, 0.3f, 0.1f, 0.1f), Color.Red);

            rect.Start <Grow>();
        }