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

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 pipe pieces. 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 left empty.

主站蜘蛛池模板: 石嘴山市| 云梦县| 双城市| 汕头市| 郓城县| 洞头县| 大兴区| 普格县| 平潭县| 桓仁| 浦江县| 南部县| 奎屯市| 清河县| 永修县| 玉溪市| 惠来县| 忻城县| 塔城市| 华坪县| 福贡县| 社会| 司法| 紫云| 博湖县| 姚安县| 无为县| 晴隆县| 姜堰市| 阿拉善盟| 巴林右旗| 榕江县| 伊金霍洛旗| 白朗县| 屏边| 巴彦淖尔市| 金川县| 棋牌| 宝应县| 砚山县| 宜兰市|