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

Creating Flexibility with the Component Object Model

In the last chapter, we saw how the Singleton pattern can help us solve the problem of creating and using the big core engines of our game. The engine code is designed to work with any game, meaning there is nothing gameplay-specific about it. So as the game design evolves, we don't need to worry about changes in game design breaking our engine. The goal when writing code for a graphics or physics engine is to make it as reusable or game-agnostic as possible. This means that when you are done making the current game, you should be able to use the code in the next game with very little or no change. The way to do this is to separate the engine code from anything related to the specific game.

Game objects, on the other hand, are completely specific to our game. If the game changes, all our object types will need to change as well. If we are making a platformer and suddenly change to making a Space Shooter, our graphics and physics engine code probably doesn't need to change. However, every single game object and behavior will change. While this may be the most extreme example, the fact is that our game objects are likely to change a lot. So let's look at how we can use patterns to solve this small, but very important, piece of our game.

主站蜘蛛池模板: 涪陵区| 临潭县| 当涂县| 贡嘎县| 来安县| 迁西县| 重庆市| 广宗县| 芜湖县| 南岸区| 凤庆县| 迁西县| 博客| 开平市| 阳朔县| 象州县| 钟山县| 托克逊县| 馆陶县| 汽车| 山东省| 鄂托克旗| 贵南县| 阿拉善左旗| 宣武区| 杭锦旗| 广河县| 临海市| 武穴市| 克拉玛依市| 鸡东县| 石景山区| 靖边县| 周宁县| 南丹县| 安仁县| 宜君县| 安新县| 五寨县| 深州市| 榕江县|