Example #1
0
        /// <summary>
        /// Updates the camera
        /// </summary>
        public void Update(PlayerShip player, bool thirdPerson)
        {
            switch (thirdPerson)
            {
            case true:
                position = player.Position + player.Rotation.Backward * 1f + player.Rotation.Up * .1f;

                break;

            case false:
                position = player.Position + player.Rotation.Forward * .075f;

                break;
            }
            cameraRotation = player.Rotation;

            roll  = player.Roll;
            yaw   = player.Yaw;
            pitch = player.Pitch;

            UpdateViewMatrix();
            projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45), 400f / 300f, 0.1f, 50000f);
        }
Example #2
0
        /// <summary>
        /// Loads the required content for the game.
        /// </summary>
        public void LoadContent()
        {
            if (content == null)
            {
                content = new ContentManager(screenManager.Game.Services, "Content");
            }

            skybox = new Skybox(content);

            font = content.Load <SpriteFont>("Fonts/gameFont");

            bulletSprite = content.Load <Texture2D>("bulletSprite");

            crossHair = content.Load <Texture2D>("crosshair");

            // Texture and model for ship.
            ship        = content.Load <Model>("spaceship");
            shipTexture = content.Load <Texture2D>("interceptormap2");

            primarySound = content.Load <SoundEffect>("lasershot");

            blankTexture = content.Load <Texture2D>("whiteText");

            effect = content.Load <Effect>("effects");

            // Texture and model for asteroids.
            sphere        = content.Load <Model>("sphere");
            sphereTexture = content.Load <Texture2D>("AM1");

            explosion = content.Load <SoundEffect>("Explo4");

            player = new PlayerShip(ship, shipTexture, 60);

            CreateWorldObjects();

            bullets = new List <Bullet>();
        }