官术网_书友最值得收藏!

Time for action – updating Game1 to update animated pieces

  1. Modify the Update() method of the Game1 class by replacing the current case statement for the GameState.Playing state with the following:
    Case GameStates.Playing
        timeSinceLastInput +=
          (CSng(gameTime.ElapsedGameTime.TotalSeconds))
    
        If _gameBoard.ArePiecesAnimating() Then
            _gameBoard.UpdateAnimatedPieces()
        Else
            _gameBoard.ResetWater()
            Dim y As Integer
            For y = 0 To GameBoard.GameBoardHeight
                CheckScoringChain(_gameBoard.GetWaterChain(y))
            Next
            _gameBoard.GenerateNewPieces(True)
            If (timeSinceLastInput >= MinTimeSinceLastInput) Then
                HandleMouseInput(Mouse.GetState())
            End If
        End If

What just happened?

This method is very similar to its previous incarnation. In this instance, we check to see if there are outstanding animated pieces to process. If there are, then UpdateAnimatedPieces() will run. If no animated pieces currently exist, the previous behavior of the GameStates.Playing case is executed.

Drawing animated pieces

Our animated pieces are almost completed. In fact, they all function right now, but you cannot see them because we have not yet updated Draw() to take them into account.

主站蜘蛛池模板: 栖霞市| 兰坪| 福海县| 贞丰县| 司法| 肥乡县| 寿阳县| 镶黄旗| 彰武县| 丰台区| 墨竹工卡县| 太谷县| 新竹县| 南部县| 英山县| 宣城市| 定西市| 左权县| 马尔康县| 乐至县| 芮城县| 上思县| 海城市| 永靖县| 开原市| 灵璧县| 南华县| 南阳市| 武山县| 天台县| 宁明县| 灵寿县| 个旧市| 伊春市| 岱山县| 东兴市| 宾阳县| 崇左市| 韶山市| 民乐县| 基隆市|