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

The GamePiece class

The GamePiece class represents an individual pipe on the game board. One GamePiece has no knowledge of any other game pieces (that is, the responsibility of the GameBoard class), but it will need to be able to provide information about the pipe to objects that use the GamePiece class. Our class has the following requirements:

  • Identify the sides of each piece that contain pipe connectors
  • Differentiate between game pieces, which are filled with water and which are empty
  • Allow game pieces to be updated
  • Automatically handle rotation, by changing the piece type to the appropriate new piece type
  • Given one side of a piece, provide the other sides of the piece in order to facilitate determining how water can flow through the game board
  • Provide a rectangle that will be used when the piece is drawn to locate the graphic for the piece on the sprite sheet

Identifying a GamePiece

While the sprite sheet contains 13 different images, only 12 of them are actual game pieces (the last one is an empty square). Of the 12 remaining pieces, only six of them are unique pieces. The other six are the water-filled versions of the first six images.

Each of the game pieces can be identified by which sides of the square contain a connecting pipe. This results in two straight pieces and four pieces with 90 degree bends in them.

Instead of treating filled pieces as separate piece types, a second value can be tracked to determine if the piece is filled with water or not.

主站蜘蛛池模板: 封丘县| 建水县| 安顺市| 津市市| 桦南县| 宁南县| 乐清市| 翁牛特旗| 屯门区| 郧西县| 阿拉善右旗| 青浦区| 隆德县| 蚌埠市| 丹东市| 高密市| 灵台县| 静海县| 裕民县| 石景山区| 启东市| 颍上县| 陈巴尔虎旗| 芦山县| 昌都县| 武功县| 华阴市| 合江县| 阳信县| 蚌埠市| 伊宁市| 礼泉县| 谷城县| 九江市| 赣榆县| 板桥市| 开阳县| 辽阳市| 林芝县| 石台县| 贞丰县|