XNA 策略游戏应使用哪些设计模式?
我正在创建一个基于 XNA 的实时策略游戏。哪些设计模式值得考虑?
I'm creating a real-time strategy game based on XNA. Which design patterns are worth considering?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不应该专注于如何围绕特定的设计模式来设计应用程序,而应该在应用程序中找到这些模式,然后使用特定的设计模式简化代码。首先花一些时间设计游戏,然后返回阅读< /a> 设计模式如何适合您的应用程序。重要的是要记住设计模式用于简化您的代码,除非该模式确实存在,否则您不会受益。
Rather than concentrating on how to design your application around particular design patterns, you should find the patterns in your application and then simplify the code with particular design patterns. First spend some time designing your game, and then go back and read up on how design patterns could fit your application. It is important to remember that design patterns are used to simplify your code, and you don't benefit unless the pattern is actually there.
“蝇量级。”它允许使用少量内存来构建大型游戏地图。内存大小不再那么重要了。 :)
可能是一些图形效果的“装饰器”。
您可以对游戏树使用“Composite”。
但请记住,模式并不是 RTS 的要素 - 你会发现你要面对比这更大的挑战。
"Flyweight." It allows a large game map for a small amount of memory. Not that memory size matters much anymore. :)
Possibly "Decorator" for some of the graphic effects.
You can use "Composite" for the game tree.
But just keep in mind that patterns are not what make a RTS - you'll find you have bigger challenges to face than this.
不要那样设计。将系统拆分为子系统,定义哪些子系统可以相互通信,确定哪些类组成子系统。创建原型
那个设计的。在开发系统的过程中你会了解到越来越多的细节。迭代整个过程。
如果您正确执行此操作,那么最后您将在代码中看到“设计模式”。
Do not design like that. Split the system in subsystems, define which subsystem can communicate with each other, identify which classes compose the subsystem. Create a prototype
of that design. During the process of developing the system you will realize more and more details. Iterate the whole process.
If you do this right then at the end of it you will see "design patterns" in your code.