是用于商业计算机游戏的MVC设计模式 [英] Is the MVC design pattern used in commercial computer games

查看:52
本文介绍了是用于商业计算机游戏的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.

在游戏中,这两个世界彼此更接近.游戏世界(模型)通常是位于某个虚拟空间中的一组实体.游戏视图也是位于某些虚拟空间中的一组实体.界外的体积,动画,位置等,您认为属于视图"的所有事物也都直接由模型"使用:动画会影响物理和AI等.

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.

最终结果是,游戏中模型与视图之间的界限是任意的,无济于事:您最终将在它们之间复制状态的 lot .

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天全站免登陆