是商用电脑游戏中使用的MVC设计模式吗 [英] Is the MVC design pattern used in commercial computer games

查看:18
本文介绍了是商用电脑游戏中使用的MVC设计模式吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MVC 设计模式是否用于商业电脑游戏?

Is the MVC design pattern used in commercial computer games?

特别是在高性能游戏方面,我很好奇游戏行业是否有 MVC 的商业用户?

Particularly with regard to high performance games I am curious if there have been any commercial users of MVC in the games industry?

推荐答案

在游戏中很少使用.我花了一段时间才弄清楚原因,但这是我的想法:

It's rarely used in games. It took me a while to figure out why, but here's my thoughts:

MVC 的存在是为了区分两种表示.模型是数据的抽象表示.这是机器如何查看您的应用程序的状态.视图(和控制器)以对人类有意义的方式代表了该系统更具体的可见实例.

MVC exists to make a distinction between two representations. The Model is the abstract representation of your data. It's how the machine views the state of your application. The View (and Controllers) represent a more concrete visible instantiation of that system in a way that's meaningful to humans.

在大多数商业应用中,这两个世界大不相同.例如,电子表格的模型只是一个二维值网格.它不必考虑单元格的像素宽度、滚动条的位置等.同时,电子表格视图不知道单元格值是如何计算或存储的.

In most business apps, these two worlds are pretty different. For example, a spreadsheet's model is simply a 2D grid of values. It doesn't have to think about how wide the cells are in pixels, where the scrollbars are, etc. At the same time, the spreadsheet view doesn't know how cell values are calculated or stored.

在游戏中,这两个世界的距离要近得多.游戏世界(模型)通常是位于某个虚拟空间中的一组实体.游戏视图也是位于某个虚拟空间中的一组实体.边界体积、动画、位置等,所有你认为属于视图"的东西也直接被模型"使用:动画可以影响物理和人工智能等.

In a game, those two worlds are much closer to each other. The game world (model) is typically a set of entities positioned in some virtual space. The game view is also a set of entities positioned in some virtual space. Bounding volumes, animation, position, etc., all things you would consider part of the "view" are also directly used by the "model": animation can affect physics and AI, etc.

最终的结果是游戏中模型和视图之间的界限将是任意的并且没有帮助:您最终会在它们之间复制很多状态.

The end result is that the line between model and view in a game would be arbitrary and not helpful: you'd end up duplicating a lot of state between them.

相反,游戏倾向于沿着领域边界解耦事物:人工智能、物理、音频、渲染等将尽可能分开.

Instead, games tend to decouple things along domain boundaries: AI, physics, audio, rendering, etc. will be kept as separate as possible.

这篇关于是商用电脑游戏中使用的MVC设计模式吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆