public void Should_not_move_by_default() { var guy = new Guy(); guy.myTexture = new FakeTexture2D() { OnHeight = () => 1, OnWidth = () => 1 }; var bounds = new Rectangle(0, 0, 1000, 1000); guy.InitPosition(bounds); guy.Handle(new KeyboardState()); var time = new SimulatedGameTime(); guy.UpdateSprite(bounds, time.Increment(new TimeSpan(0,0,2))); Assert.That(guy.Position, Is.EqualTo(new Vector2(500, 999))); guy.UpdateSprite(bounds, time.Increment(new TimeSpan(0, 0, 5))); Assert.That(guy.Position, Is.EqualTo(new Vector2(500, 999))); }
public void Should_bounce_at_edge() { var guy = new Guy(); var bounds = new Rectangle(0, 0, 1000, 1000); guy.InitPosition(bounds); guy.Handle(new KeyboardState(new[] { Keys.Down })); guy.myTexture = new FakeTexture2D() { OnHeight = ()=> 1, OnWidth = ()=> 1 }; var positions = new List<Vector2>(); positions.Add(guy.Position); var time = new SimulatedGameTime(); guy.UpdateSprite(bounds, time.Increment(new TimeSpan(0, 0, 5))); positions.Add(guy.Position); guy.UpdateSprite(bounds, time.Increment(new TimeSpan(0, 0, 5))); positions.Add(guy.Position); Assert.That(positions.ToArray(), Is.EquivalentTo(new[] { new Vector2(500, 1000), new Vector2(500, 999), new Vector2(500, 749) })); }
public void PointTo(Guy guy) { var direction = (guy.Position - this.spritePosition); direction.Normalize(); this.spriteSpeed = direction * 50.0f; }
public void Should_start_at_bottom_middle() { var guy = new Guy(); guy.InitPosition(new Rectangle(0, 0, 100, 100)); Assert.That(guy.Position, Is.EqualTo(new Vector2(50, 100))); }
public World() { guy = new Guy(); bird = new Bird(); }