示例#1
0
文件: Game.cs 项目: grimm004/shmup
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            FrameCounter = new FrameCounter();

            Width  = SettingsManager.Current.width;
            Height = SettingsManager.Current.height;
            Graphics.PreferredBackBufferWidth  = Width;
            Graphics.PreferredBackBufferHeight = Height;
            Graphics.IsFullScreen = SettingsManager.Current.fullScreen;
            Graphics.SynchronizeWithVerticalRetrace = false;

            this.IsMouseVisible = SettingsManager.Current.isMouseVisible;

            LogFile = new FileStream("Shmup\\debug.log", FileMode.Append);

            Graphics.ApplyChanges();
            base.Initialize();
        }
示例#2
0
文件: Game.cs 项目: grimm004/shmup
 /// <summary>
 /// This is called when the game should draw itself.
 /// </summary>
 /// <param name="gameTime">Provides a snapshot of timing values.</param>
 protected override void Draw(GameTime gameTime)
 {
     FrameCounter.Update((float)gameTime.ElapsedGameTime.TotalSeconds);
     if (activeScreen != null)
     {
         GraphicsDevice.Clear(activeScreen.BackgroundColour);
     }
     else
     {
         GraphicsDevice.Clear(Color.Black);
     }
     spriteBatch.Begin();
     if (activeScreen != null && activeScreen.GetType() == typeof(GameScreen))
     {
         gameScreen.DrawGame(gameTime, spriteBatch);
     }
     if (activeScreen != null)
     {
         activeScreen.Draw(spriteBatch);
     }
     spriteBatch.End();
     base.Draw(gameTime);
 }