/// <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) { // TODO: Add your drawing code here #region Scrolling States FSM - Controlling Background Colour switch (scrollingState) { // Start and leaderboard screens case (ScrollingStates.IdleScrolling): { // Only use one colour, just like the walls. GraphicsDevice.Clear(Color.CornflowerBlue); break; } // Pregame, high score, and game over screens case (ScrollingStates.NotScrolling): { // Freeze-frame with the current colour. GraphicsDevice.Clear(currentColour); break; } // Actual gameplay case (ScrollingStates.Scrolling): { // Cycle through the colours in levelUpAnimation.bgColourArray, as // long as the text is still scrolling on-screen. if (levelUpAnimation.HasLeveledUp) { levelUpAnimation.ChangeBgColour(GraphicsDevice); } // Otherwise, do not cycle, and instead display a random colour // from bgColourArray. else { GraphicsDevice.Clear(currentColour); } break; } } #endregion spriteBatch.Begin(); #region Game States FSM - Draw() portion switch (gameState) { case (GameStates.StartScreen): { // Draw a "live" background of the game. wallManager.DrawAll(spriteBatch); // Overlay the start screen's components above the live background. startScreen.Draw(spriteBatch); break; } case (GameStates.Leaderboard): { // Draw a "live" background of the game. wallManager.DrawAll(spriteBatch); // Overlay the leaderboard screen's components above the live background. leaderboardScreen.Draw(spriteBatch, leaderboard.HiScores); break; } case (GameStates.Pregame): { // Draw a static image of the game's initial state. wallManager.DrawAll(spriteBatch); player.Draw(spriteBatch); scoreCounter.Draw(spriteBatch); levelCounter.Draw(spriteBatch); // Overlay the pregame screen on top. pregameScreen.Draw(spriteBatch); break; } case (GameStates.Playing): { wallManager.DrawAll(spriteBatch); player.Draw(spriteBatch); scoreCounter.Draw(spriteBatch); levelCounter.Draw(spriteBatch); levelUpAnimation.Draw(spriteBatch); break; } case (GameStates.HiScore): { // Draw a static image of the game's current state. wallManager.DrawAll(spriteBatch); player.Draw(spriteBatch); scoreCounter.Draw(spriteBatch); levelCounter.Draw(spriteBatch); // Overlay the high score screen above the current game state. hiScoreNameEntryScreen.Draw(spriteBatch); break; } case (GameStates.GameOver): { // Draw a static image of the game's current state. wallManager.DrawAll(spriteBatch); player.Draw(spriteBatch); scoreCounter.Draw(spriteBatch); levelCounter.Draw(spriteBatch); // Overlay the game over screen on top. gameOverScreen.Draw(spriteBatch); gameOverScreen.Draw(spriteBatch, scoreCounter, levelCounter); break; } } #endregion spriteBatch.End(); base.Draw(gameTime); }