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

Classes used in Flood Control

While it would certainly be possible to simply pile all of the game code into the Game1 class, the result would be difficult to read and manage later on. Instead, we need to consider how to logically divide the game into classes that can manage themselves and help to organize our code.

A good rule of thumb is that a class should represent a single thing or type of thing. If you can say "This object is made up of these other objects" or "This object contains these objects", consider creating classes to represent those relationships.

The Flood Control game contains a game board made up of 80 pipes. We can abstract these pipes as a class called GamePiece, and provide it with the code it needs to handle rotation and provide the code that will display the piece with a Rectangle that can be used to pull the sprite off the sprite sheet.

The game board itself can be represented by a GameBoard class, which will handle managing individual GamePiece objects and be responsible for determining which pieces should be filled with water and which ones should be empty.

主站蜘蛛池模板: 吉隆县| 巨野县| 灯塔市| 神池县| 金湖县| 海伦市| 铜山县| 克山县| 于都县| 晴隆县| 同德县| 扶风县| 新民市| 开原市| 彝良县| 涞源县| 郧西县| 四平市| 新建县| 瓦房店市| 中阳县| 九龙县| 黎平县| 公主岭市| 繁峙县| 延长县| 岳阳县| 呈贡县| 阜新| 铜梁县| 千阳县| 九龙县| 剑河县| 泉州市| 石嘴山市| 张北县| 科技| 泸西县| 溧阳市| 晴隆县| 玉门市|