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

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.

主站蜘蛛池模板: 上蔡县| 崇义县| 阿拉善左旗| 乐陵市| 彭水| 桦南县| 河曲县| 陆川县| 和龙市| 高台县| 夏河县| 石屏县| 称多县| 东阿县| 拉萨市| 友谊县| 清远市| 云林县| 南康市| 中江县| 南涧| 微山县| 修文县| 望都县| 郴州市| 万山特区| 额敏县| 额尔古纳市| 泗水县| 米易县| 苍山县| 蒙阴县| 晋江市| 昭觉县| 合作市| 绥德县| 浦县| 瑞丽市| 都匀市| 荔浦县| 肇源县|