游戏框架架构——视图组件还是 MVC? [英] Game framework architecture - view components or MVC?

查看:35
本文介绍了游戏框架架构——视图组件还是 MVC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的游戏构建一个非常轻量级的可重用框架,而不是每次开始游戏时都从头开始.我有一个组件驱动的架构 - 例如Entity 由 Position 组件、Health 组件和 Ai 组件等组成.

I'm trying to build a very light re-usable framework for my games, rather than starting from scratch each time I start a game. I have a component driven architecture - e.g. Entity composes a Position component and a Health component and Ai component etc.

我的大问题是我的模型是否组合视图组件以允许模型的多个视图,或者是否在模型不知道其视图的情况下使用更真实的 MVC,并且它们由外部管理.

My big question is whether my model composes view components to allow for more than one view of the model, or whether to use a truer MVC where the model does not know about its views, and they are managed externally.

我已经尝试了这两种方法,但如果有人知道每种方法的优缺点以及行业标准,那就太好了.

I have tried both methods but if anyone knows the pros and cons of each approach and which is the industry standard, it would be great to know.

推荐答案

取决于你的观众,游戏开发者,包括我自己都不是很习惯 MVC 模型,虽然大多数人都知道,但保持它的清洁并不容易削减,因为开发人员伤亡(不是任何严重的技术原因).所以从经验来看,我见过几十个游戏框架从 MVC 开始,但只有一对能够维持到最后.我的理论是 MVC 为小型一次性游戏(通常只有几个开发人员)增加了太多的复杂性和很少的好处,并且很难将大多数游戏对象真正干净地分离到大型/复杂游戏的这些层中.而且由于游戏有发布日期,它们很多时候会牺牲代码的清晰度和可重用性来换取性能和快速的临时解决方案(如果续集有必要的话(如果有的话),它们会被重写).

depends on your audience, game devs, myself included aren't very used to the MVC model, although most know it, it's not as easy to keep it clean cut, because of development casualties (not any serious technical reasons). So from experience, I've seen dozens of game frameworks start as MVC, but only a pair were able to maintain it until the end. My theory is MVC adds too much complexity and little benefits for small throwaway games (with normally a few devs), and it's to hard to keep really cleanly separate most game objects into these layers for large/complex games. And since games have a release date, they many times sacrifice code clarity and reusability for performance and quick adhoc solutions (that will get rewritten if necessarry in the sequel (if there is one)).

但是,根据上面的警告,最好把目标定得很高,因为如果你成功了,那就更好了:),如果你失败了,那就不好了.所以你可能应该尝试 MVC,但如果它失败了也不用担心,专业的游戏开发者在任务上都失败了很多次 :)

However, with the caveat above, it's better to aim high, because if you succeed it's better :) and if you fail, well to bad. So you should probably try the MVC, but don't worry if it fails, profesional game devs have all failed at the task many times :)

这篇关于游戏框架架构——视图组件还是 MVC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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