HTML and CSS Reference
In-Depth Information
// fractional tick, the code rounds up.
var clockTick = g.intdiv( - this.startTime, g.MS_PER_TICK);
if (this.tick > clockTick) {
// This means that the game time is ahead of real
// time, don't process more frames.
Server Commands
A server command is a special command that must be processed at the time it is issued in order for the game to
progress beyond that time. As mentioned earlier, commands from clients may be dropped if the client is catching up
and processing more FPS than the server. To force all clients to process all server commands, clients will not process
a game update until the server command list for that tick has been received, and the server will produce exactly
one command for every tick. This is similar to the lockstep model described previously but only applies to server
commands. To prevent server commands from causing the client to stutter (the main drawback with the lockstep
model), an artificially high latency is given to all server commands. This causes a delay in server commands, but this
delay is acceptable, because server commands are not time sensitive.
Client-Side Prediction
In FrightCycle , client-side prediction is handled by the CLIENT_SIDE_PREDICTION variable in globals.js . Try setting
this variable to false , and see the effect. Now, clients will wait until they have inputs from all other clients before
processing the next frame. If you have a fast connection to the server, you may not notice the difference, but with a
slow connection, you will notice sporadic delays; the game, however, will never be in an inconsistent state.
As FrightCycle demonstrates, the complexity of implementing a real-time network multiplayer game is trading off
latency for correctness of the current state. At one extreme, a lockstep model without client-side prediction will ensure
that all users have complete state information at the expense of high latency. The additional latency makes the game
less responsive and can make the game difficult to play. At the other extreme, users submit actions that are effective
immediately. This provides instant user feedback but causes jittering, as the game engine is constantly rolled back to
apply user commands retroactively and then fast-forwarded to the present time with the additional user inputs.
Search WWH ::

Custom Search