Time for action – letting the player play

  1. Modify the Update() method of Game1.cs by adding the following before the call to base.Update(gameTime):
    switch (gameState)
    {
        case GameStates.TitleScreen:
            if (Keyboard.GetState().IsKeyDown(Keys.Space))
            {
                gameBoard.ClearBoard();
                gameBoard.GenerateNewPieces(false);
                playerScore = 0;
                gameState = GameStates.Playing;
            }
            break;
    
        case GameStates.Playing:
            timeSinceLastInput +=
              (float)gameTime.ElapsedGameTime.TotalSeconds;
    
            if (timeSinceLastInput >= MinTimeSinceLastInput)
            {
                HandleMouseInput(Mouse.GetState());
            }
    
            gameBoard.ResetWater();
    
            for (int y = 0; y < GameBoard.GameBoardHeight; y++)
            {
                CheckScoringChain(gameBoard.GetWaterChain(y));        
            }
    
            gameBoard.GenerateNewPieces(true);
    
            break;
    }

What just happened?

The Update() method ...

Get XNA 4.0 Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.