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

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.

主站蜘蛛池模板: 夹江县| 抚州市| 龙陵县| 修文县| 包头市| 兰考县| 六枝特区| 通河县| 项城市| 民和| 正镶白旗| 象山县| 贡嘎县| 张家界市| 太保市| 阜新| 合作市| 湄潭县| 蓝山县| 克什克腾旗| 永泰县| 准格尔旗| 岫岩| 九龙坡区| 洪江市| 绥化市| 竹北市| 和平县| 舞阳县| 安泽县| 晴隆县| 霍邱县| 定日县| 集贤县| 贺州市| 女性| 通城县| 双江| 三门县| 浪卡子县| 吉林省|