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

The GameBoard class

Now that we have a way to represent pieces in memory, the next logical step is to create a way to represent an entire board of playing pieces.

The game board is a two-dimensional array of GamePiece objects, and we can build in some additional functionality to allow our code to interact with pieces on the game board by their X and Y coordinates.

The GameBoard class needs to:

  • Store a GamePiece object for each square on the game board
  • Provide methods for code using the GameBoard to update individual pieces, by passing calls through to the underlying GamePiece instances
  • Randomly assign a piece type to a GamePiece
  • Set and clear the "Filled with water" flags on individual GamePieces
  • Determine which pipes should be filled with water, based on their position and orientation, and mark them as filled
  • Return lists of potentially scoring water chains to code using the GameBoard
主站蜘蛛池模板: 万源市| 浪卡子县| 尼木县| 安康市| 通城县| 乌兰察布市| 新绛县| 邓州市| 滦平县| 延津县| 阿坝县| 锡林浩特市| 鹤峰县| 邵阳县| 峨眉山市| 额济纳旗| 卢湾区| 六枝特区| 晴隆县| 张家界市| 新闻| 松原市| 磐安县| 如东县| 钦州市| 宜宾县| 若尔盖县| 区。| 巴楚县| 长汀县| 盐城市| 莲花县| 平南县| 三门县| 大姚县| 乐业县| 惠安县| 宁河县| 梧州市| 禄丰县| 昌邑市|