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

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.

主站蜘蛛池模板: 鹿邑县| 盱眙县| 横山县| 揭东县| 通河县| 宁阳县| 应城市| 怀柔区| 罗山县| 镇沅| 平江县| 资源县| 婺源县| 介休市| 新密市| 邓州市| 洛隆县| 二手房| 古丈县| 镶黄旗| 屯门区| 广元市| 什邡市| 三亚市| 永修县| 牟定县| 龙门县| 商洛市| 搜索| 合水县| 固始县| 揭西县| 佛坪县| 民和| 通化县| 青冈县| 仁怀市| 涿鹿县| 正镶白旗| 信丰县| 堆龙德庆县|