Time for action – adding difficulty levels
Add the following declarations to the
Game1
class:Private currentLevel As Integer = 0 Private linesCompletedThisLevel As Integer = 0 Private Const floodAccelerationPerLevel As Single= 0.5 Private levelTextPosition As Vector2 = new Vector2(512, 215)
Add the
StartNewLevel()
method to theGame1
class:Private Sub StartNewLevel() currentLevel += 1 floodCount = 0.0 linesCompletedThisLevel = 0 floodIncreaseAmount += floodAccelerationPerLevel _gameBoard.ClearBoard() _gameBoard.GenerateNewPieces(false) End Sub
Modify the
Update()
method of theGame1
class by replacing the case section forGameState.TitleScreen
with the following:Case GameStates.TitleScreen If (Keyboard.GetState().IsKeyDown(Keys.Space)) Then playerScore = 0 currentLevel = 0 floodIncreaseAmount = 0.0 StartNewLevel() gameState = GameStates.Playing End If
Modify the
CheckScoringChain()
method to increment thelinesCompletedThisLevel...