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

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.

主站蜘蛛池模板: 南宁市| 抚顺县| 兴山县| 雷波县| 呼伦贝尔市| 牡丹江市| 襄城县| 日土县| 溆浦县| 始兴县| 赤水市| 博野县| 无锡市| 寿宁县| 重庆市| 临猗县| 乌拉特后旗| 嘉善县| 翁源县| 滨州市| 双鸭山市| 呈贡县| 安顺市| 汉寿县| 红河县| 民县| 大同县| 平安县| 嘉黎县| 永兴县| 铁岭县| 雅江县| 桐柏县| 额敏县| 永州市| 外汇| 沁源县| 商丘市| 乌恰县| 淳安县| 安仁县|