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

Time for action – modify Game1 to generate rotating pieces

  1. Update the HandleMouseInput() method in the Game1 class to add rotating pieces to the board by adding the following inside the "if mouseInfo.LeftButton = ButtonState.Pressed" block, before _gameBoard.RotatePiece() is called:
    _gameBoard.AddRotatingPiece(x, y,
        _gameBoard.GetSquare(x, y), False)
  2. Still in HandleMouseInput(), add the following in the same location inside the if block for the right-mouse button:
    _gameBoard.AddRotatingPiece(x, y,
        _gameBoard.GetSquare(x, y), True)

What just happened?

Recall that the only difference between a clockwise rotation and a counter-clockwise rotation (from the standpoint of the AddRotatingPiece() method) is a true or false in the final parameter. Depending on which button is clicked, we simply add the current square (before it gets rotated, otherwise the starting point for the animation would be the final position) and true for right-mouse clicks or false for left-mouse clicks.

Calling UpdateAnimatedPieces()

In order for the UpdateAnimatedPieces() method of the GameBoard class to run, the game's Update() method needs to be modified to call it.

主站蜘蛛池模板: 大安市| 电白县| 广德县| 龙口市| 长顺县| 台江县| 桃园市| 慈利县| 宜春市| 镇雄县| 兴文县| 冕宁县| 泰和县| 绥宁县| 玉环县| 吉林市| 彝良县| 鄂托克前旗| 加查县| 广水市| 巴彦淖尔市| 汶川县| 教育| 屏南县| 堆龙德庆县| 鄂托克前旗| 安新县| 广南县| 昭平县| 新竹县| 北宁市| 安仁县| 通山县| 潞西市| 安阳县| 巴青县| 文昌市| 龙泉市| 东港市| 武胜县| 烟台市|