Ejemplo n.º 1
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
                content = new ContentManager(ScreenManager.Game.Services, "Content");

            _background = content.Load<Texture2D>("Backgrounds/sunset");

            _particleEngine = new ParticleEngine(content);

            _gameEngine = new Engine(ScreenManager.Game.Services, _particleEngine)
                {
                    GraphicsDevice = ScreenManager.GraphicsDevice
                };

            _camera = new Camera2D(ScreenManager.Game, _gameEngine);

            _hud = new HUD(_camera);

            // Load the level.
            string levelPath = string.Format("Content/Levels/{0}.txt", 0);
            using (Stream fileStream = TitleContainer.OpenStream(levelPath))
            {
                _gameEngine.Initialize(fileStream, _camera, _hud);

                _camera.Focus = _gameEngine.Player;

                _hud.Initialize(content);

                //todo: implement video setting for postprocessing
                _postprocessor = new GraphicalPostprocessor(true);
                _postprocessor.Initialize(ScreenManager.Game);
            }

            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();
        }