[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] people hating python for game dev.



Actually, I used my own protocol and just used the twisted.internet functions.  I started with UDP but later converted to TCP because I didn't want to deal with dropped messages and firewall issues.  Blender has some issues running twisted directly, so I have to convert incoming packets into something blender can pick up anyway - I run twisted as a seperate process.

It would be interesting to see how pb could work in a game situation though, I haven't spent a lot of time looking at all of twisted.  All I know is it's a really nice easy way to come up with a really stable server with minimal effort :)
Just for some insight into my protocol, I handle it similarly to the way twisted handles things.  I chop up the stream by a specific endpacket character, and buffer everything up to that point.  Each packet contains a type, a data portion, and the packet's sender (ip/port).  In the udp version, I needed that sender portion as udp is connectionless.  In the tcp version, I just append the sender to the packets after they have arrived.  My client class then has a function to deal with packets, and it delegates each packet to a corresponding function based on the packet type.  So when a clientstate packet comes in, it will run the clientstate function on the packet's data.

After the initial set-up, which took a couple weeks, I barely have to think about the networking portion anymore, besides making sure that the proper things happen in the right place (serverside or clientside).  When I switched to tcp it did take me about a week to get everything working as expected, but still, the turnaround for this project continues to surprise me!

I haven't really done much to make everything efficient yet, I am still in the making stuff work phase.  I try not to be too wasteful, but I figure it will be better to optomize things when I have all the features in place.

But, back on topic, python rocks for game development!  Just check out all of the awesome games made for pyweek, and you can tell it's no slouch.  It is pretty slow if you try to use 100% python, but with hardware-accelerated optomized use of pygame, you can do nes-snes quality, and with pyopengl or a dedicated game engine, you can do just about anything.