Game Development Reference
In-Depth Information
The following illustration is of a typical game loop. It's true for single player games
as well as multiplayer games, except that multiplayer games must need to log in to
a game server, send messages to the server, and process the messages received from
the server.
Initialize
Login
EnterAvatar
Process User Input
Render Screen
Publish Updates
to Server
Receive & process
Network Msgs
We will learn a great deal about each of them in the coming chapters, but at this
point, it should give you a fairly good idea of how things look from the top.
Initialize is where the program loads the resources it needs, for example, loading
art assets from the disk. Upon a successful login to the server, it registers the avatar
the player has entered. Typically, others in the game lobby would see a name
representing the avatar either when the player chats or enters the game room waiting
to be played. Also, the avatar's buddies or friends are notified whenever the avatar
enters the game.
The main loop constantly reads the user input, be it a mouse, keyboard, or any other
form of input device. The various update methods are also called on the game. For
example, the input processor may detect that a left arrow is held down, resulting in
the avatar's spaceship steering to the left. The graphics display is constantly redrawn
or refreshed each time in the loop.
Any user actions that need to be seen by others in the game or in the vicinity are
sent up to the server as messages. The server then broadcasts these messages to the
players clients, and when received, triggers further visual updates and so on.
 
Search WWH ::




Custom Search