|
|

楼主 |
发表于 2005-3-2 22:59:00
|
显示全部楼层
Re:请问一下游戏的程序的大体框架是什么样的?
我是想做一个网络的小型动作游戏 我的设想是做成一个小球在屏幕上运动 通过上下左右来控制
我在一篇资料里看到 它说的服务器和客户端的构架是这样说的 (用到了FrameTime)
Figure 1: General Client / Server Architecture
For this discussion, all of the messaging and coordination needed to start up the connection between client and server is omitted. The client’s frame loop looks something like the following:
{Sample clock to find start time
Sample user input (mouse, keyboard, joystick)
Package up and send movement command using simulation time
Read any packets from the server from the network system
Use packets to determine visible objects and their state
Render Scene
Sample clock to find end time
End time minus start time is the simulation time for the next frame}
Each time the client makes a full pass through this loop, the “frametime” is used for determining how much simulation is needed on the next frame. If your framerate is totally constant then frametime will be a correct measure. Otherwise, the frametimes will be incorrect, but there isn’t really a solution to this (unless you could deterministically figure out exactly how long it was going to take to run the next frame loop iteration before running it…).
The server has a somewhat similar loop:
{Sample clock to find start time
Read client user input messages from network
Execute client user input messages
Simulate server-controlled objects using simulation time from last full pass
For each connected client, package up visible objects/world state and send to client
Sample clock to find end time
End time minus start time is the simulation time for the next frame}
In this model, non-player objects run purely on the server, while player objects drive their movements based on incoming packets. Of course, this is not the only possible way to accomplish this task, but it does make sense.
我就搞不懂它说的 simulation time 是怎么用的?
|
|