예제 #1
0
 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)));
 }
예제 #2
0
 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) }));
 }