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

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.

主站蜘蛛池模板: 商洛市| 得荣县| 屯留县| 南昌县| 靖江市| 读书| 乐东| 噶尔县| 瑞昌市| 玉门市| 龙南县| 兴隆县| 冷水江市| 富锦市| 横山县| 象山县| 农安县| 札达县| 乌鲁木齐县| 化隆| 芜湖县| 张家口市| 南漳县| 轮台县| 宝坻区| 北川| 西宁市| 松桃| 安岳县| 九龙城区| 定日县| 体育| 南投县| 靖西县| 团风县| 全南县| 称多县| 江口县| 东兴市| 通河县| 扬中市|