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()); }
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); }
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 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()); }
public void RenderGrowingRotatingRectangle() { var rect = new FilledRect(new Rectangle(0.3f, 0.3f, 0.1f, 0.1f), Color.Red); rect.Start<Grow>(); }
public void RenderGrowingRotatingRectangle() { var rect = new FilledRect(new Rectangle(0.3f, 0.3f, 0.1f, 0.1f), Color.Red); rect.Start <Grow>(); }