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

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.

主站蜘蛛池模板: 石首市| 巴林右旗| 盐山县| 邹平县| 石河子市| 农安县| 封开县| 兰州市| 新泰市| 宣恩县| 文化| 辽阳县| 辰溪县| 广宁县| 隆回县| 津市市| 龙海市| 枣强县| 新乡县| 泸溪县| 岳池县| 南岸区| 兴文县| 信宜市| 金华市| 金湖县| 阜新市| 延长县| 仪陇县| 卫辉市| 成武县| 本溪市| 商丘市| 林西县| 郸城县| 图木舒克市| 陕西省| 南漳县| 鲜城| 彭州市| 综艺|