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

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.

主站蜘蛛池模板: 鱼台县| 吉林省| 昂仁县| 奉化市| 甘南县| 三原县| 庆元县| 沅陵县| 顺义区| 呈贡县| 无为县| 永州市| 仪陇县| 新野县| 上高县| 白银市| 金门县| 兴和县| 富顺县| 龙里县| 新干县| 磐石市| 漳平市| 朔州市| 施秉县| 夏津县| 安阳县| 吴桥县| 富宁县| 颍上县| 巴林左旗| 靖江市| 北京市| 长岭县| 玉环县| 卢氏县| 钟祥市| 镇雄县| 朝阳区| 庆阳市| 蒲城县|