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

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.

主站蜘蛛池模板: 南涧| 高雄市| 宿松县| 玉山县| 随州市| 民勤县| 天峨县| 乌海市| 岳阳县| 黎平县| 泾源县| 富宁县| 台南市| 米林县| 土默特左旗| 鄂托克旗| 凤凰县| 河西区| 电白县| 苗栗市| 临城县| 子长县| 鄯善县| 章丘市| 万山特区| 上栗县| 青冈县| 峨眉山市| 临泉县| 台南市| 定襄县| 通江县| 海晏县| 石首市| 呼和浩特市| 梨树县| 威远县| 田东县| 金湖县| 峨眉山市| 疏附县|