Exemplo n.º 1
0
        /// <summary>
        ///   Creates a default orthographic camera and lets it respond to the provided
        ///   controls once with a 1 second update.
        /// </summary>
        /// <param name="keyboardState">
        ///   Keyboard state that will be reported to the camera
        /// </param>
        /// <param name="gamePadState">
        ///   GamePad state that will be reported to the camera
        /// </param>
        /// <returns>The camera after it has responded to the provided controls</returns>
        private Camera handleControlsOnDefaultCamera(
            KeyboardState keyboardState, GamePadState gamePadState
            )
        {
            Camera camera = Camera.CreateDefaultOrthographic();

            camera.HandleControls(OneSecondGameTime, keyboardState, gamePadState);
            return(camera);
        }
Exemplo n.º 2
0
        public void TestHandleControls()
        {
            Camera camera = Camera.CreateDefaultOrthographic();

            camera.HandleControls(OneSecondGameTime);

            // We can't make assumptions about which keys the user held down while
            // the unit test ran, so we just verify it's not blowing up.
        }
Exemplo n.º 3
0
        public void TestKeyboardDownMovement()
        {
            Camera camera = handleControlsOnDefaultCamera(Keys.F);
            Camera defaultOrthographic = Camera.CreateDefaultOrthographic();

            Assert.AreEqual(defaultOrthographic.Position.X, camera.Position.X);
            Assert.Greater(defaultOrthographic.Position.Y, camera.Position.Y);
            Assert.AreEqual(defaultOrthographic.Position.Z, camera.Position.Z);
        }
Exemplo n.º 4
0
        public void TestDefaultOrthographic()
        {
            Camera defaultCamera = Camera.CreateDefaultOrthographic();

            Assert.AreEqual(Vector3.Zero, defaultCamera.Position);

            // The point should end up in front of the camera
            Vector3 leftPoint   = -Vector3.UnitZ;
            Vector3 transformed = Vector3.Transform(leftPoint, defaultCamera.View);

            Assert.Less(transformed.Z, 0.0f);
        }