After reading this getting started with Cocomo tutorial by Ryan Stewart, I made a stupid little proof-of-concept for a multiplayer pong game. A pong game is dropdead simple, but I came across an interesting problem related to multiplayer games that I never thought about before because this is my first multiplayer game attempt ever (so cut me some slack here please
). I had an issue to effectively and seemlessly synchronize the position of the ball between the two users. Note that synchronization events only come in maximum 10 times per second and this isn't fast enough to create a smooth animation. Just compare the movement of the ball (which is smooth) and the movement of your opponent's paddle (which is very jumpy). I only synchronize the common position of the ball every time it bounces on a player's paddle. For example, the left player catches the ball and at that time I send the ball's properties to the Cocomo server. A bit later, the right player receives that synchronization event containing the ball's position and moving direction. But since the time that the left user sent out the coordinates, the ball has already moved on. The solution was simply to predict the position of the ball using the latency time. I regularly calculate a user's network latency and with this value I can predict the current coordinates of the ball because I know the speed of the ball over the X & Y axis. It's a simple as that.
Please note that this proof-of-concept needs exactly 2 users. If you're alone, you can open 2 browser windows next to each other and move around. (If you happen to see paddles waving around, this means somebody else is fooling around already.)
The source isn't viewable yet, coz I have to clean it a bit first (and the thing probably still has got some bugs in there too).
Here's a great article going deep into the problem of lag compensation: http://developer.valvesoftware.com/wiki/Lag_Compensation

