The Basic Game Loop基本游戏环节
There is a basic formula that almost every game, that is what is called a "game loop". The game loop is just a series of procedures for getting input and displaying output to the player and updating the game. There are 3 basic processes that go on inside a game loop and 2 outside of it.
这是几乎所有游戏的基础规则,这就是为什么它为成为"游戏环节"。游戏环节是一个系列的过程,目的是为了让玩家可以输入并显示信息给玩家,以及可以更新游戏。文中有三条游戏环节的基本步骤以及两条相关的建议。
Starting the Game开始游戏
The beginning of every game usually consists of an animation sequence to show off some aspect of the game's story or background and an option menu for starting the game or changing various parameters that affect the game in some way. Those parameters often include sound volume, graphic options, multiplayer options, difficulty and starting level.
通常,游戏开始时播放一段用来说明游戏背景故事的动画,并显示出控制的主菜单以供玩家开始游戏或者通过某种方式来修改游戏中多方面的参数以调整游戏中的效果。这些参数通常包含音量调节、图像调节、多人游戏设置、难度以及开始关卡。
Player Input玩家输入
These routines will take the player's input from whatever device they are using and store it in a way that the game can process to make changes to the game internals.
这些标准程序实现让玩家可以通过可以使用的任何设备来完成输入的功能,并且可以通过游戏内的设置来调整输入的按键。
Updating Game Internals游戏内部的更新
These routines are the real guts of the game. Everything from moving the player's character using their input, to the actions of the enemies and determining whether the player has won or lost the game is determined here.
这部分程序是游戏真正的内涵。所有的事情都基于玩家对角色的控制,实现同敌人的互动以及决定玩家是胜利还是失败。
Displaying the Screen在屏幕上显示
This actually can be done in two ways. You can either draw everything to the screen at one time or what is more commonly done, set everything up to be drawn and then draw the screen afterwards. Drawing the screen can take longer than most processes in a game so you want to do it all at one time. Determining what is necessary to be drawn can take a relatively long time with all the checks your game could have, so it's best to do this before you actually try to commit your graphics to the screen or video hardware.
实现显示功能有两条路。如果不是一次在屏幕上画出所有图片,那么就是象通常的那样,先将图片读出来然后再画到屏幕上去。在屏幕上画图可能比游戏中的多数过程都要长,所以你会想一次把它都画出来。先确定什么是必须画的,这就可以腾出相对长一些的时间去检查你的游戏,所以最好在你把图形实际应用于屏幕和视频硬件之前先做好这一点。
Ending the Game游戏结局
Once the game is over there is normally an ending sequence, or at least something that says goodbye to the player.
一旦游戏结束了就在这里播放结局,或者至少跟玩家说声再见。
Conclusion结论
Understanding what elements go into creating a game loop can definitely make starting your first game easier. Before you start programming anything, sit down and draw out a small flowchart or list of things you want to have happen and for the player to see. You'll find it makes the actual programming and end result much better.
理解什么是构成游戏环节的元素,可以使你更容易实现自己的第一个游戏。在你开始用代码写什么以前,先坐下来画个小小的流程图或者把你准备给玩家看的东西做个列表。你将发现这样做会让你的代码及效果更好。
There is a basic formula that almost every game, that is what is called a "game loop". The game loop is just a series of procedures for getting input and displaying output to the player and updating the game. There are 3 basic processes that go on inside a game loop and 2 outside of it.
这是几乎所有游戏的基础规则,这就是为什么它为成为"游戏环节"。游戏环节是一个系列的过程,目的是为了让玩家可以输入并显示信息给玩家,以及可以更新游戏。文中有三条游戏环节的基本步骤以及两条相关的建议。
Starting the Game开始游戏
The beginning of every game usually consists of an animation sequence to show off some aspect of the game's story or background and an option menu for starting the game or changing various parameters that affect the game in some way. Those parameters often include sound volume, graphic options, multiplayer options, difficulty and starting level.
通常,游戏开始时播放一段用来说明游戏背景故事的动画,并显示出控制的主菜单以供玩家开始游戏或者通过某种方式来修改游戏中多方面的参数以调整游戏中的效果。这些参数通常包含音量调节、图像调节、多人游戏设置、难度以及开始关卡。
Player Input玩家输入
These routines will take the player's input from whatever device they are using and store it in a way that the game can process to make changes to the game internals.
这些标准程序实现让玩家可以通过可以使用的任何设备来完成输入的功能,并且可以通过游戏内的设置来调整输入的按键。
Updating Game Internals游戏内部的更新
These routines are the real guts of the game. Everything from moving the player's character using their input, to the actions of the enemies and determining whether the player has won or lost the game is determined here.
这部分程序是游戏真正的内涵。所有的事情都基于玩家对角色的控制,实现同敌人的互动以及决定玩家是胜利还是失败。
Displaying the Screen在屏幕上显示
This actually can be done in two ways. You can either draw everything to the screen at one time or what is more commonly done, set everything up to be drawn and then draw the screen afterwards. Drawing the screen can take longer than most processes in a game so you want to do it all at one time. Determining what is necessary to be drawn can take a relatively long time with all the checks your game could have, so it's best to do this before you actually try to commit your graphics to the screen or video hardware.
实现显示功能有两条路。如果不是一次在屏幕上画出所有图片,那么就是象通常的那样,先将图片读出来然后再画到屏幕上去。在屏幕上画图可能比游戏中的多数过程都要长,所以你会想一次把它都画出来。先确定什么是必须画的,这就可以腾出相对长一些的时间去检查你的游戏,所以最好在你把图形实际应用于屏幕和视频硬件之前先做好这一点。
Ending the Game游戏结局
Once the game is over there is normally an ending sequence, or at least something that says goodbye to the player.
一旦游戏结束了就在这里播放结局,或者至少跟玩家说声再见。
Conclusion结论
Understanding what elements go into creating a game loop can definitely make starting your first game easier. Before you start programming anything, sit down and draw out a small flowchart or list of things you want to have happen and for the player to see. You'll find it makes the actual programming and end result much better.
理解什么是构成游戏环节的元素,可以使你更容易实现自己的第一个游戏。在你开始用代码写什么以前,先坐下来画个小小的流程图或者把你准备给玩家看的东西做个列表。你将发现这样做会让你的代码及效果更好。