Synchronizing client states
After you've got game clients talking to each other comes the challenge of working out what they should actually say, and that can be a more difficult problem than what one might initially suspect.
Presented in this example are the beginnings of a multiplayer-networked version of Pong, or more specifically, a simulation of two clients and a server instance of a game of Pong.
With this simulation, you'll hopefully get a chance to experiment with and discover some useful strategies on how to architect holding and transferring state between networked clients.
Getting ready
This example relies upon a single texture file named block
, from which it stretches into various sizes to form the onscreen elements. Any texture will do but I would recommend a small, completely white texture as a starting point.
How to do it...
To see a working example of synchronization:
1. Begin a new class to simulate the gameplay with the various bits of state pertinent to the game:
class Simulation...