这种类型的游戏循环咋看上去非常好,但别被蒙了。
This kind of game loop may seem very good at first sight, but don't be fooled.
正如我在介绍中所说,所谓游戏循环就是每个游戏的心跳。
Just like I said in the introduction, the game loop is the heartbeat of every game.
另一种游戏循环的实现就是让其尽可能快地运行,然后让FPS控制游戏速度。
Another implementation of a game loop is to let it run as fast as possible, and let the FPS dictate the game speed.
在本文我不会深入前面提到的各种任务的详细实现,而是专注于游戏循环这一点。
In this article I will not go into details on any of the above mentioned tasks, but will concentrate on the game loop alone.
但别担心,因为你正好遇到这篇文章,这是唯一一篇给予游戏循环应有重视的文章。
But fear not, because you have just stumbled upon the one and only article that gives the game loop the attention it deserves.
当使用可变步长的游戏循环时,你将要表示游戏单元每毫秒的值,比如一个精灵移动的距离。
When using a variable-step game loop, you should express rates—such as the distance a sprite moves—in game units per ms.
为了减少一个游戏循环中所做的操作的次数,我们添加了一个用来将游戏循环分隔为多个游戏循环的系统。
To reduce the number of operations to do in a game cycle, a system to split up computation over several game cycles was added.
多亏作为游戏程序员的工作,我能接触到大量小型手机游戏的代码,并且总让我惊奇地发现如此之多的游戏循环的实现方式。
Thanks to my job as a game programmer, I come into contact with a lot of code for small mobile games. And it always amazes me how many game loop implementations are out there.
但运行在低速的硬件下时,帧速率会下降直到游戏更新循环抵达MAX_FRAMESKIP。
When running on slow hardware, the framerate can drop until the game update loop will reach MAX_FRAMESKIP.
这个简单循环的问题在于它忽略了时间,游戏仅仅在运行。
The problem with this simple loop is that it doesn't handle time, the game just runs.
如果他们不一遍又一遍的提高自己编写保龄球游戏代码的技巧,他们很可能会让数据库陷入死循环。
And when they're not perfecting the art of writing bowling games over and over again, they just might hit the database in loop.
视频游戏是以新主机发售开始每五六年为一个循环的工业。
Video gaming is a cyclical industry in which new consoles are launched every five or six years.
我经常玩着玩着就电脑椅上睡着了,然后几个小时候醒来继续游戏,如此循环反复。
Often times I would fall asleep in my chair in front of my computer with EverQuest running, waking up hours later to start the cycle all over again.
从结构上来说,这个主循环非常简单。上面的代码片段基本上能够囊括你的游戏的整个工作过程。
Structurally, the loop is very simple. The above snippet of code can encapsulate the entire workings of your game.
在每次进入循环的时候,我们会执行游戏逻辑的更新,输入更新与处理,还有渲染。
Each time through the loop, we perform game logic updates, input updating and handling, and rendering.
其可能造成的结果是游戏玩家在游戏事件循环的某一部分按下了发射键,而在另一部分却松开了它。所以必须在同一处进行采样与读入输入。
It's possible that the player might have the fire button down in one part of the event loop and not in another, so you must sample at the same point you read the input for the game normally.
基于恒定游戏速度的FPS的主循环实现方案简单易学。
Making the game state independent of the FPS seems to be the best implementation for a game loop.
基于恒定游戏速度的FPS的主循环实现方案简单易学。
Making the game state independent of the FPS seems to be the best implementation for a game loop.
应用推荐