|
From: | Vincent Caron |
Subject: | Re: [Underware-devel] Networked pong |
Date: | Wed, 21 Jan 2004 15:12:36 +0100 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 |
Loic Dachary wrote:
The pong example currently in the CVS implements a protocol that allows two players to play together. It works on a lan but I doubt it would work over the internet. A server sits between the two players. At present the protocol looks like this:
It looks like the protocol is stateless. I guess it's a false impression : a version packet will be received first, then not be expected anymore during any client lifetime. My 2 cents to suggest to adopt or get inspiration from one of the many 5th layer protocols (not HTTP, too simple). Actually designing the state diagram for the game and the network protocol should be pretty close (which player is getting in, loosing, striking a ball, quitting, etc).
When ever the ball bounces (table border or paddle) it sends a throwball packet to the server. Each client synchronize with this event, ensuring that no client can drift significantly from another.
Strictly speaking, sending throwball packets only on _paddle_ collisions is sufficient since nothing interfere with the paddle trajectory between two paddle strokes.
The python integration for the whole set of packet classes is generated by the underware/builder.pl script based on the c_template.{h,cpp}, all_template.{h,cpp}, bind_template.{cpp} templates. The human written part of the binding (transform C++ member to python object) is written in bind_<class>.cpp. All these classes are in the underware directory.
It's a _very_ good thing, it gives a better idea of the real work needed to have bindings working.
[Prev in Thread] | Current Thread | [Next in Thread] |