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

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



Cool that you got your protocol sorted out so that it sounds pretty much
automated :)
 
My first trial run at writing a prototype was basic a tuple of allowed
commands which I then had python execute as an indentically named python
(each command was a string and I did something similar to eval, can't
remember off the top of my head). I realised afterwards that even though I
was checking against a list of allowed commands, the scope was there to let
people in and arbitrarily execute python code.
 
I discovered the Perspective Broker stuff kind of by accident, but once I
started with it, I wanted to use it more and more. In a nutshell, it saves
you having to write up a command translator, or even specify commands to
begin with in that you have a specific set of functions that are allowed by
prefixing a "public" function with "remote_".
 
Quite fittingly, the class that you subclass from to control an individual
client session is called Avatar :)
 
Even though it sounds like you're chugging along quite happily with what you
have, I highly recommend checking out PB via the twisted main site (
http://twistedmatrix.com/projects/core/documentation/howto/pb-intro.html
<http://twistedmatrix.com/projects/core/documentation/howto/pb-intro.html>
).

-----Original Message-----
From: owner-pygame-users@xxxxxxxx [mailto:owner-pygame-users@xxxxxxxx]On
Behalf Of Patrick Mullen
Sent: Tuesday, May 16, 2006 18:12
To: pygame-users@xxxxxxxx
Subject: 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. 






CONFIDENTIAL NOTICE: This email including any attachments, contains 
confidential information belonging to the sender. It may also be 
privileged or otherwise protected by work product immunity or other 
legal rules. This information is intended only for the use of the 
individual or entity named above.  If you are not the intended 
recipient, you are hereby notified that any disclosure, copying, 
distribution or the taking of any action in reliance on the contents 
of this emailed information is strictly prohibited.  If you have 
received this email in error, please immediately notify us by 
reply email of the error and then delete this email immediately.