O'Reilly logo

Multiplayer Game Development with HTML5 by Rodrigo Silveira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The game loop

As you know, the game loop is the very core of any real-time game. Although the game loop serves a fairly simple function, let us now consider some of the implications of having a game server and client running together.

Frame rate independence

The purpose of the game loop is nothing more than to ensure that the game runs in a consistent, ordered manner. For example, if we draw the current game state before we update it, the player might find the game to be slightly out of sync when they interact with it since the current display would be at least one frame behind what the player would expect it to be.

In addition, and this is particularly so in JavaScript's event-based input system, if we update the game every time we receive input ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required