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

Time for action – water in the pipes

  1. Add a method to the GameBoard class to clear the water marker from all pieces:
    Public Sub ResetWater()
      Dim x, y As Integer
      For x = 0 To GameBoardWidth
        For y = 0 To GameBoardHeight
          boardSquares(x, y).RemoveSufix("W")
        Next
      Next
    End Sub
  2. Add a method to the GameBoard class to fill an individual piece with water:
    Public Sub FillPiece(x As Integer, y As Integer)
      boardSquares(x, y).AddSuffix("W")
    End Sub

What just happened?

The ResetWater() method simply loops through each item in the boardSquares array and removes the W suffix from the GamePiece. Similarly, to fill a piece with water, the FillPiece() method adds the W suffix to the GamePiece. Recall that by having a W suffix, the GetSourceRect() method of GamePiece shifts the source rectangle one tile to the right on the sprite sheet, returning the image for a pipe filled with water, instead of an empty pipe.

Propagating water

Now that we can fill individual pipes with water, we can write the logic to determine which pipes should be filled depending on their orientation.

主站蜘蛛池模板: 宜兰县| 甘德县| 北安市| 谢通门县| 托里县| 金乡县| 郧西县| 石柱| 家居| 滦南县| 界首市| 莱州市| 宣恩县| 石渠县| 洛隆县| 镇雄县| 水城县| 武山县| 吴桥县| 秀山| 浏阳市| 临漳县| 陇川县| 赣州市| 渭南市| 孟州市| 固安县| 定远县| 元谋县| 海城市| 凤冈县| 隆尧县| 耒阳市| 同江市| 祁东县| 江达县| 定襄县| 建宁县| 丹棱县| 海南省| 金昌市|