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

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.

主站蜘蛛池模板: 涟源市| 桃江县| 双牌县| 嫩江县| 舒城县| 南华县| 泾阳县| 洱源县| 玉溪市| 竹溪县| 汨罗市| 阿拉尔市| 香港 | 姚安县| 浦县| 舞阳县| 新田县| 克什克腾旗| 顺平县| 贵州省| 兰溪市| 板桥市| 安阳县| 大埔区| 蓬莱市| 拉萨市| 固阳县| 琼结县| 全椒县| 葫芦岛市| 哈巴河县| 遂昌县| 隆回县| 太康县| 富蕴县| 沧源| 乐清市| 阳西县| 镇安县| 富宁县| 三台县|