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

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.

主站蜘蛛池模板: 滦南县| 错那县| 读书| 台东市| 沭阳县| 珠海市| 嘉峪关市| 宽甸| 确山县| 潢川县| 诏安县| 江川县| 河北省| 济宁市| 抚远县| 合水县| 登封市| 酒泉市| 周口市| 桂林市| 稷山县| 兴仁县| 沙河市| 锦州市| 勃利县| 涿州市| 巩义市| 界首市| 迭部县| 蒙山县| 饶平县| 曲周县| 灵武市| 贡觉县| 汨罗市| 邢台县| 肃宁县| 西峡县| 昭平县| 花莲市| 克山县|