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

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.

主站蜘蛛池模板: 吴桥县| 东光县| 阳泉市| 乐都县| 赣州市| 洛川县| 综艺| 沅陵县| 渭源县| 池州市| 成都市| 玉屏| 曲阳县| 平顺县| 东乌珠穆沁旗| 图片| 平泉县| 井陉县| 宜丰县| 上高县| 微山县| 洞口县| 海宁市| 怀远县| 金湖县| 平遥县| 巧家县| 孝昌县| 甘洛县| 定安县| 深圳市| 全椒县| 盐津县| 缙云县| 鹿泉市| 新安县| 河北省| 腾冲县| 武安市| 石渠县| 石狮市|