Adding Draw Code
The final step is adding code to draw the game. Replace your existing Draw method in the Game1 class with the following:
protected override void Draw(GameTime gameTime)
{
// Only draw when game is active
if (this.IsActive)
{
// Based on the current game state,
// call the appropriate method
switch (currentGameState)
{
case GameState.SignIn:
case GameState.FindSession:
case GameState.CreateSession:
GraphicsDevice.Clear(Color.DarkBlue);
break;
case GameState.Start:
DrawStartScreen( );
break;
case GameState.InGame:
DrawInGameScreen(gameTime);
break;
case GameState.GameOver:
DrawGameOverScreen( );
break;
}
}
base.Draw(gameTime);
}This method, like the Update method, will
perform certain actions only when the game is active. This is to prevent drawing
when the gamer services windows are open. The method then calls other methods based
on the game state.
Notice that the SignIn, FindSession, and CreateSession game states do nothing but draw a blank screen by
calling GraphicsDevice.Clear. This is because
other gamer services activities are going on during these game states, and no
drawing on the screen is needed.
So, let's start with the next one. Add the following DrawStartScreen method to your Game1 class:
private void DrawStartScreen( ) { // Clear screen GraphicsDevice.Clear(Color.AliceBlue); // Draw text for intro splash screen spriteBatch.Begin( ); // Draw instructions string text = "The dynamite player chases the gears\n"; text += networkSession.Host.Gamertag + " is the ...