/// <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) { // Render everything in scene activator. SceneActivator.Render(spriteBatch, GraphicsDevice); #if DEBUG_INFO // Check if debug and showfps. if (SHOW_FPS) { // Render fps to screne. _fps.Render(spriteBatch, GraphicsDevice); } #endif // Call base draw. base.Draw(gameTime); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Get the spritebatch. spriteBatch = new SpriteBatch(GraphicsDevice); #if DEBUG_INFO // Load debug font. SpriteFont font = Content.Load <SpriteFont>("Font/DebugFont"); // If debug mode + SHOW_FPS create fps counter. if (SHOW_FPS) { _fps = new FpsCounter(font); } #endif // Start intro scene. SceneActivator.ActivateScene(new IntroScene(this)); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Check if game should close. if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } /* * If an update takes too long, we want to set the elapsed time to 41ms * this is to prevent strange physics based bugs * The game can play on lower framerate * But the updates will be done on 24 fps calculations. */ // Check gametime is more than 41 milliseconds (24fps). if (gameTime.ElapsedGameTime.TotalMilliseconds > 41f) { // set gametime to 41 milliseconds. gameTime.ElapsedGameTime = new System.TimeSpan(0, 0, 0, 0, 41); } // Update keyboard device. KeyboardDevice.Update(gameTime); // Update scene activator. SceneActivator.Update(gameTime); // Call keyboard endframe. KeyboardDevice.EndFrame(); #if DEBUG_INFO // check if debug + SHOW_FPS if (SHOW_FPS) { // Update fps counter. _fps.Update(gameTime); } #endif // Update base. base.Update(gameTime); }