Game Development Reference
In-Depth Information
Each player within the game must perceive pretty much the same state of the game.
The enemy of multiplayer gaming is Lag . It is something that can destroy a player's
experience. The way to approach lag is simply to not add more lag in the software
layers, such as buffering messages for no apparent reason, avoiding under utilization
of CPU with badly written multithreaded implementations, etc.
A game server's responsibility is not only to exchange data but also for validation
and synchronization.
Validation is mostly against modified or hacked clients that, for example, may claim to
never decrease life, carry infinite ammunition, or walk through walls, etc. The server
spends a considerable amount of CPU making sure all players have a fair game.
Synchronization is where the server avoids two players from picking up one weapon
that's on the ground. If two players claim something, the server is the ultimate
arbitrator in deciding who wins. The server simply processes the message in a first-
come-first-serve basis. Another example is the server in a racing game having the
final say on who crossed the finishing line first. If you have played enough online
racing games, you will sometimes notice that on your screen you seemed to have
won the race by a hair, but the server reports back otherwise. This is due to the fact
that the client continues to draw your car's position while the exact position of your
opponent has not arrived and thus not displayed.
Modeling game states
Depending on your game, you may need to define more than one game state. Each
subclass of the game must have the parent set to GameState . The following are the
property descriptions defined in the GameState class:
Developer Usable Property
Notes
Action
A server-reserved property; the
developer should not use this for
any purpose.
State type
The developer should set the value
of this property upon creating a
game state object. Possible values for
this property are:
GameConstants.GS_IS_INITIAL
GameConstants.GS_IS_MUTABLE
GameConstants.GS_IS_
TRANSIENT
GameConstnats.GS_IS_UNIQUE
Search WWH ::




Custom Search