コード例 #1
0
ファイル: GuyTests.cs プロジェクト: wallymathieu/a_xna_game
 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
ファイル: GuyTests.cs プロジェクト: wallymathieu/a_xna_game
 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) }));
 }
コード例 #3
0
ファイル: Bird.cs プロジェクト: wallymathieu/a_xna_game
 public void PointTo(Guy guy)
 {
     var direction = (guy.Position - this.spritePosition);
     direction.Normalize();
     this.spriteSpeed = direction * 50.0f;
 }
コード例 #4
0
ファイル: GuyTests.cs プロジェクト: wallymathieu/a_xna_game
 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)));
 }
コード例 #5
0
ファイル: Game1.cs プロジェクト: wallymathieu/a_xna_game
 public World()
 {
     guy = new Guy();
     bird = new Bird();
 }