科技: 人物 企业 技术 IT业 TMT
科普: 自然 科学 科幻 宇宙 科学家
通信: 历史 技术 手机 词典 3G馆
索引: 分类 推荐 专题 热点 排行榜
互联网: 广告 营销 政务 游戏 google
新媒体: 社交 博客 学者 人物 传播学
新思想: 网站 新书 新知 新词 思想家
图书馆: 文化 商业 管理 经济 期刊
网络文化: 社会 红人 黑客 治理 亚文化
创业百科: VC 词典 指南 案例 创业史
前沿科技: 清洁 绿色 纳米 生物 环保
知识产权: 盗版 共享 学人 法规 著作
用户名: 密码: 注册 忘记密码?
    创建新词条
科技百科
  • 人气指数: 1158 次
  • 编辑次数: 1 次 历史版本
  • 更新时间: 2011-12-03
明天
明天
发短消息
相关词条
盘点十大愚蠢的游戏营销活动
盘点十大愚蠢的游戏营销活动
盘点十大最经典的格斗游戏
盘点十大最经典的格斗游戏
盘点史上十大最经典策略游戏
盘点史上十大最经典策略游戏
盘点五大最失望的游戏
盘点五大最失望的游戏
盘点十大被各国禁售的游戏
盘点十大被各国禁售的游戏
盘点当今11大黑客风格游戏
盘点当今11大黑客风格游戏
2014年E3最佳游戏名单
2014年E3最佳游戏名单
2013年游戏业9大AI趋势
2013年游戏业9大AI趋势
2014年游戏行业十大趋势
2014年游戏行业十大趋势
2014年最值得期待的25款独立游戏
2014年最值得期待的25款独立游戏
推荐词条
希拉里二度竞选
希拉里二度竞选
《互联网百科系列》
《互联网百科系列》
《黑客百科》
《黑客百科》
《网络舆情百科》
《网络舆情百科》
《网络治理百科》
《网络治理百科》
《硅谷百科》
《硅谷百科》
2017年特斯拉
2017年特斯拉
MIT黑客全纪录
MIT黑客全纪录
桑达尔·皮查伊
桑达尔·皮查伊
阿里双十一成交额
阿里双十一成交额
最新词条

热门标签

微博侠 数字营销2011年度总结 政务微博元年 2011微博十大事件 美国十大创业孵化器 盘点美国导师型创业孵化器 盘点导师型创业孵化器 TechStars 智能电视大战前夜 竞争型国企 公益型国企 2011央视经济年度人物 Rhianna Pratchett 莱恩娜·普莱契 Zynga与Facebook关系 Zynga盈利危机 2010年手机社交游戏行业分析报告 游戏奖励 主流手机游戏公司运营表现 主流手机游戏公司运营对比数据 创建游戏原型 正反馈现象 易用性设计增强游戏体验 易用性设计 《The Sims Social》社交亮 心理生理学与游戏 Kixeye Storm8 Storm8公司 女性玩家营销策略 休闲游戏的创新性 游戏运营的数据分析 社交游戏分析学常见术语 游戏运营数据解析 iPad风行美国校园 iPad终结传统教科书 游戏平衡性 成长类型及情感元素 鸿蒙国际 云骗钱 2011年政务微博报告 《2011年政务微博报告》 方正产业图谱 方正改制考 通信企业属公益型国企 善用玩家作弊行为 手机游戏传播 每用户平均收入 ARPU值 ARPU 游戏授权三面观 游戏设计所运用的化学原理 iOS应用人性化界面设计原则 硬核游戏 硬核社交游戏 生物测量法研究玩家 全球移动用户 用户研究三部曲 Tagged转型故事 Tagged Instagram火爆的3大原因 全球第四大社交网络Badoo Badoo 2011年最迅猛的20大创业公司 病毒式传播功能支持的游戏设计 病毒式传播功能 美国社交游戏虚拟商品收益 Flipboard改变阅读 盘点10大最难iPhone游戏 移动应用设计7大主流趋势 成功的设计文件十个要点 游戏设计文件 应用内置付费功能 内置付费功能 IAP功能 IAP IAP模式 游戏易用性测试 生理心理游戏评估 游戏化游戏 全美社交游戏规模 美国社交游戏市场 全球平板电脑出货量 Facebook虚拟商品收益 Facebook全球广告营收 Facebook广告营收 失败游戏设计的数宗罪名 休闲游戏设计要点 玩游戏可提高认知能力 玩游戏与认知能力 全球游戏广告 独立开发者提高工作效率的100个要点 Facebook亚洲用户 免费游戏的10种创收模式 人类大脑可下载 2012年最值得期待的20位硅谷企业家 做空中概股的幕后黑手 做空中概股幕后黑手 苹果2013营收 Playfish社交游戏架构

优化游戏运行效果的7个基本原则 发表评论(0) 编辑词条

目录

优化游戏运行效果的7个基本原则编辑本段回目录

作者:Cliff Harris

制作运行更为快速的游戏是我所关注的话题之一。提供特别的代码范例只能帮助到某些人,下文我将公布某些普遍使用的原则。

1、避开使用代码的设计。

这听起来确实让人感到害怕,但是人们还是会这么做。诸如肩膀和膝盖之类的“皮肤化”动画对CPU而言较难以处理。你在游戏中看不到多少有着较大肩垫的角色。这种做法会让设计工作更为简单。GSB是款2D游戏,主要原因在于我偏好2D游戏玩法,但是我不能忽略一个事实,那就是游戏不适宜在支持3D的CPU/GPUG的环境中运行。

GSB(from cpugamer.com)

GSB(from cpugamer.com)

2、离线运行代码。

如果你的代码输出是一次性的,那么这种做法只能够使用一次,而且要在你传输游戏之前。GSB战役游戏代码在计算行星移动距离时显得尤为低效和缓慢。代码的运行是一次性的,然后在运行期间装载进结果即可。如果游戏在运行时间内进行的计算是基于永不改变的数据,可以预先对这些数据进行计算而后装载成表格。

3、运行一次代码,然后进行缓冲。

这是最后的重大胜利。在之前的年代里,人们使用正余弦表格来查找结果,而不是真正进行计算。GSB在某些方面也采用这种做法(游戏邦注:对游戏可玩性不是很重要的部分)。如果你可以在计算一次后直接引用结果,那么就不要在相同的功能中进行第二次运算。如此做法能够产生的差异性令人震惊。即便是像STL列表end()调用等简单的事项也能堆积成大型存储器。

4、无需每帧都运行代码。

没有那么多代码需要每帧都去运行。GSB中的小地图并没有每帧都更新。你会注意到这点吗?我不会注意到,因为在多数帧中,船只的移动是“次像素”的。如果需要运行代码的话,那么就要在某帧中更新半个代码,然后在下帧中再更新另一半代码。帧率应当设定为1/60秒。没有人会注意到代码没有随帧更新。

5、看不到的东西无需进展。

GSB中有某些用于各种装饰物品的代码,只会在屏幕上有活动性发生时才会调用。从理论上来说,你可以暂停游戏,或许会发现周围有些微小的矛盾(游戏邦注:假设玩家运气够好的话)。在战略游戏中,多数时间下,多数动作并没有被查看到,所以你可以舍去所有这些东西。比如,我就不更新运行离屏光线的计时器。

6、对内容进行重新排序和分组。

显卡喜欢集中分组处理事情。比如,提供单一纹理和50个精灵,它们会很乐意接受。但是,如果提供的是有着不同纹理的50个精灵,情况可能就有所不同了。这就是所有GSB残骸都使用相同纹理的原因。我也在游戏代码中对船只重新进行排序,这样相似的船只就可以在同个批次绘制出来,即便绘制的只是图标。这使得纹理交换达到最小化。因为GSB不使用z缓冲器,这使得代码有些混乱,但这是值得的。我找到的最简单的系统是保持不同纹理的精灵列表。你仍然会像往常那样绘制精灵,但是当绘制完成后这些精灵会被归类到相关列表中,随后整个列表中的精灵都可以绘制完成。

7、在不繁忙的时候保存内容。

GSB采用了这种方法。这确实非常棘手,但是你可以使用那些只会在CPU空闲时运行的代码。如果激光束集中GSB中的某些残骸,那么残骸就会爆炸。这只会在CPU空闲的时候发生。人们偶尔会注意到这点,认为这是l33t。但是他们并没有发现这种情况并非总会发生。

注意:优化UI

人们获得了运行快速的引擎,却发现其中UI运行格外缓慢。这足以让人发疯!大量的文字、图标、对话框背景和多部分按键,这些都有可能使得界面过载、纹理交换过度并大幅降低效率。你应当注意到这一点。

不要忘记,你同样可以对纹理进行优化。某些纹理已经足够成熟,可以进行压缩,但是有些纹理还做不到,但是你可以对其采取措施,比如将某个循环纹理分离成4部分,将其当成4个抛射和反射精灵来处理(游戏邦注:作者经常采用这种方法)。并非每个人都拥有512MB的视频卡,装载较小纹理的速度总是比较大纹理要快得多。

多数程序员可能都已经知道了这点,但是重新说下总不是什么错事。开发者很容易就会遗忘优化而只关注功能,但是如果你注意到这点,玩家会对你表示感谢。我发现许多人对GSB在其机器上的运行情况表示非常惊讶。这便是我努力的成果。

游戏邦注:本文发稿于2010年8月20日,所涉时间、事件和数据均以此为准。(本文为游戏邦/gamerboom.com编译,拒绝任何不保留版权的转载,如需转载请联系:游戏邦

Basic principles of game optimization

Cliff Harris

Making games run faster is a pet topic of mine. Code samples are too specific to help many people, so here are some general principles I’ve learned.

1) Design to avoid the code.

Sounds horrid doesn’t it, but people do it all the time. ‘Skinned’ animation at points like shoulders and knees is CPU intensive and tricky. Ever noticed how many characters in games have big shoulder-pads? Makes life much easier. GSB is a 2D game, mainly because I prefer 2D gameplay, but I can’t ignore the fact that it would be horrendously more draining on the CPU/GPU to be in 3D.

2) Run the code offline.

If the output of your code is a one-off, only ever do it once, and before you ship the game. The GSB campaign game code has some really inefficient slow brute force stuff for calculating planet-travel distances. It’s done as a one-off, and the results loaded in at run time. If there are calculations your game makes at run time that are based on data that never changes, just pre-calc them and load in a table, assuming the table is small enough.

3) Run the code once, and cache it.

This is the ultimate big win. In the old days, people used tables of cosine/sine lookups, rather than calculating them. Hold on! GSB does that for some stuff too (nothing gameplay critical). Never make a calculation twice in a function if you can do it once and reference it later. It’s amazing what a difference this makes. Even simple stuff like STL list end() calls can mount up with really large containers.

4) Don’t run the code every frame.

Not much code has to be run every frame. The minimap in GSB isn’t updated every frame. Can you notice? I can’t, because most frames a ships movement would be ‘sub-pixel’ anyway. If stuff like this seems to jitter, update half the code one frame, the other half the next frame. A frame should be 1/60th of a second. Nobody will notice.

5) Don’t process what isn’t seen.

GSB does some cunning code for all kinds of cosmetic things that only applies if that activity happens onscreen. In theory you can pause the game, scroll around and spot very minor inconsistencies (good luck). With strategy games, most of the time, most of the action isn’t being viewed, so you can skip allsorts of stuff. I don’t update timers for running lights offscreen, for example.

6) Re-order and group stuff.

Graphics cards like to do things in big clumps. Give them a single texture, and 50 sprites to draw and they are happy. Give them 50 sprites with different textures and they are not. This is why all the GSB debris is clumped into a single texture, ditto the laser bolts. I also re-order ships in the game code so that similar ones are drawn one after the other, even when drawn as icons. This minimizes texture swaps. Because GSB doesn’t use a z-buffer(for blending reasons), that makes for some spaghetti like code, but it’s worth it. The easiest system I’ve found is to maintain spritelists for different textures. You still draw sprites as normal, but when they draw they just get thrown into the relevant list, and the list gets drawn later.

7) Save stuff for when you are not busy.

GSB does this. It’s very tricky, but you can have code that only runs when the CPU is idle. If a laser bolt hits some debris in GSB, the debris explodes. This ONLY happens if the CPU is idling. People spot it occasionally and think it’s l33t. They never spot that it doesn’t happen all the time.

Optimize the UI

People get a fast engine then slap some super-slow UI on top. Madness! With a lot of text, icons, dialog box backgrounds and multi-part buttons, you can have crazy overdraw, crazy texture-swaps and huge inefficiency. Keep an eye on it.

Don’t forget that you can also optimize textures too. Some textures are ripe for compression, others not, but you can also do crazy tricks with some stuff, like chop a circle texture into one quarter, and raw it as 4 flipped and mirrored sprites (I do that a lot). Not everyone has 512 MB video cards, and its quicker to load a small texture than a big one anyway.

Most coders probably know all this already, but it doesn’t hurt to recap. It’s easy to forget about optimising and just worry about features, but gamers will thank you for it. I get a lot of people remarking how surprised they are at how well GSB runs on their machine. This is no accident. (Source: Cliffski.com)

→如果您认为本词条还有待完善,请 编辑词条

词条内容仅供参考,如果您需要解决具体问题
(尤其在法律、医学等领域),建议您咨询相关领域专业人士。
0

标签: 优化游戏运行效果的7个基本原则

收藏到: Favorites  

同义词: 暂无同义词

关于本词条的评论 (共0条)发表评论>>

对词条发表评论

评论长度最大为200个字符。