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

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.

主站蜘蛛池模板: 随州市| 东海县| 罗田县| 名山县| 广丰县| 肇州县| 扎鲁特旗| 万安县| 邢台县| 泰安市| 东丽区| 新兴县| 怀柔区| 屏南县| 错那县| 新宁县| 伊宁市| 金坛市| 兴文县| 喀喇沁旗| 灵宝市| 扎囊县| 河源市| 元氏县| 华宁县| 大庆市| 库尔勒市| 察哈| 新竹市| 台北市| 墨竹工卡县| 盘锦市| 涟源市| 武汉市| 黑龙江省| 怀来县| 松桃| 县级市| 和平县| 灵丘县| 吴旗县|