Beispiel #1
0
        public void CameraHasScreenWidthAndHeight()
        {
            Camera camera = new Camera(null, new Vector2(100, 200));

            Assert.AreEqual(100, camera.ScreenWidth);
            Assert.AreEqual(200, camera.ScreenHeight);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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));
        }
Beispiel #6
0
        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)));
        }
Beispiel #7
0
        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)));
        }