On Monday 19 November 2007 19:08:49 Jason Ward wrote: > I want to make my game playable over the network and if possible the > internet. > For the network it must support more than 2 computers and be realtime > Would the sockets library in python solve all my needs?
Simple outline of a networked pong game (just a networked bouncing ball :-) using Kamaelia for networking and pygame: http://kamaelia.svn.sourceforge.net/viewvc/kamaelia/trunk/Sketches/MPS/Pong.py?revision=3744&view=markup To run as a server: # ./Pong.py server To run the client (on the same machine) # ./Pong.py 127.0.0.1 The server runs the game model and publishes to all clients. These need to be serialised, so for the moment the message ("ballpos", 100, 200) is serialised as "ballpos|100|200X". The "X" is needed as a record separator. This makes the client slightly more complex. (Since the client needs to demarshall such messages) Other than that, that code is really divided into 4 parts. * A PygameComponent which simplfies using pygame. (To be merged at somepoint onto the mainline) * A component to handle display of scene objects * A component to handle updating the system model * A bunch of components declarations / pipelines to orchestrate behaviour. The code in that example uses some newer features of Kamaelia (mainly to assist readability), so if you want to try that code, you'll need to check out my scratch branch: svn co https://kamaelia.svn.sourceforge.net/svnroot/kamaelia/branches/private_MPS_Scratch Then install Axon (which Kamaelia depends upon, then install Kamaelia) : cd private_MPS_Scratch cd Axon sudo python setup.py install cd .. cd Kamaelia sudo python setup.py install Hope its of interest :-) Michael.