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

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.

主站蜘蛛池模板: 鄂托克旗| 锡林郭勒盟| 红原县| 乌鲁木齐县| 东辽县| 河间市| 邢台县| 祥云县| 华蓥市| 梧州市| 穆棱市| 赤壁市| 开原市| 德州市| 宝坻区| 龙口市| 九龙坡区| 牙克石市| 大悟县| 上栗县| 赤壁市| 洱源县| 林芝县| 昂仁县| 万宁市| 二连浩特市| 沙河市| 南雄市| 萝北县| 巩留县| 海口市| 绥化市| 金乡县| 正镶白旗| 湘西| 云霄县| 九寨沟县| 句容市| 德昌县| 冕宁县| 扶风县|