Time for action – letting the player play
Modify the
Update()
method ofGame1.cs
by adding the following before the call tobase.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 performs two different functions...