public void CameraHasScreenWidthAndHeight() { Camera camera = new Camera(null, new Vector2(100, 200)); Assert.AreEqual(100, camera.ScreenWidth); Assert.AreEqual(200, camera.ScreenHeight); }
public void TranslationMatrixTakesScreenSizeIntoAccount() { var player = MockRepository.GenerateStub<IPlayer>(); player.Position = new Vector2(100, 200); var camera = new Camera(player, new Vector2(400, 500)); Matrix translationMatrix = Matrix.CreateTranslation(-100 + 200, -200 + 250, 0.0f); Assert.AreEqual(translationMatrix, camera.TranslationMatrix); }
public void ReturnsCorrectTranslationMatrix() { var player = MockRepository.GenerateStub<IPlayer>(); player.Position = new Vector2(100, 200); var camera = new Camera(player, new Vector2(0, 0)); Matrix translationMatrix = Matrix.CreateTranslation(-100, -200, 0.0f); Assert.AreEqual(translationMatrix, camera.TranslationMatrix); }
public void CameraPositionBasedOnPlayerPosition() { var player = MockRepository.GenerateStub<IPlayer>(); player.Position = new Vector2(100, 200); var camera = new Camera(player, new Vector2(0, 0)); Assert.AreEqual(new Vector2(100, 200), camera.Position); player.Position = new Vector2(1, 2); Assert.AreEqual(new Vector2(1, 2), camera.Position); }
public void UsesCameraCorrectly() { Level level = new Level(null); level.Pieces.Add(LevelPieceHelper.MakeLevelPiece(new Vector2(1, 1), new Vector2(100, 100))); var stubSpriteBatch = MockRepository.GenerateStub<ISpriteBatch>(); var stubTexture = MockRepository.GenerateStub<ITexture>(); Camera camera = new Camera(MockRepository.GenerateStub<IPlayer>(), new Vector2(100, 200)); LevelView levelView = new LevelView(level, stubSpriteBatch, stubTexture, camera); levelView.Generate(1f); stubSpriteBatch.AssertWasCalled(x => x.Begin(camera.TranslationMatrix)); }
public void CanConvertCameraPointToWorldCoordinates() { var player = MockRepository.GenerateStub<IPlayer>(); player.Position = new Vector2(100, 200); var camera = new Camera(player, new Vector2(400, 500)); Matrix translationMatrix = Matrix.CreateTranslation(-100 + 200, -200 + 250, 0.0f); Assert.AreEqual(new Vector2(-50, 50), camera.ConvertToWorldCoordinates(new Vector2(50, 100))); }
public void UsesCameraCorrectly() { ICamera camera = new Camera(player, new Vector2(100, 100)); playerView = new PlayerView(playerList, _stubTextureBank, stubSpriteBatch, camera, stubWeaponDrawer, stubBubbleText); playerView.Generate(1f); stubSpriteBatch.AssertWasCalled(x => x.Begin(Arg<Matrix>.Is.Equal(camera.TranslationMatrix))); }