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

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.

主站蜘蛛池模板: 蒙山县| 新晃| 板桥市| 清涧县| 桂东县| 轮台县| 双鸭山市| 临沧市| 双鸭山市| 晋江市| 临沂市| 右玉县| 聂荣县| 巨野县| 井陉县| 福泉市| 华安县| 铁岭市| 牟定县| 吉木萨尔县| 海伦市| 华池县| 绥芬河市| 平武县| 茶陵县| 淮滨县| 新化县| 平陆县| 乌海市| 吐鲁番市| 来宾市| 衡山县| 鹤岗市| 西畴县| 葵青区| 岳阳市| 大同县| 积石山| 乌兰县| 安远县| 疏勒县|