[Twisted-Python] how to handle game messaging

glyph at divmod.com glyph at divmod.com
Thu May 15 15:18:16 EDT 2008

On 01:57 pm, ninmonkeys at gmail.com wrote:
>(1) In a game like this, or even a first person shooter: where message
>speed is more important: What is a good way to send messages to/from
>the client and server? Important ones like bullet spawning, other
>player locations, etc ?

Message speed is more important than what?  Premature optimization and 
all that.

If you're just learning Twisted, consider AMP: 

It's not particularly fast or well-suited to a first-person shooter, but 
it is easy.  Make it work, make it right, *then* make it fast.  If you 
don't understand Twisted then "easy" is a lot more important than "fast" 
until you really know what you're doing *AND* you have demonstrated you 
have a real performance issue.
>(2) Do you also send a timestamp so that if the client receives the
>message 250ms after the spawn, he can step backwards in his physics
>simulation to better simulate client-side?

Any network game should have lots of time information in the messages 
that are sent.  Stepping backwards in the physics simulation is one way 
to manage latency, but there are others, and the important thing is 
reacting to latency.
>(3) I wrote pseudo-code of how I think the asteroids code messaging
>could work. How do I improve messaging? What am I doing wrong? For my
>example I'm going to only use LAN ( so I don't have to deal with
>latency issues ). I attached the pseudo code.

Commenting on pseudo-code is kind of pointless; your description was 
vague enough that it might describe a lot of different ideas, some good, 
some bad.  Just write something and see if it works!  If it doesn't, 
then you can distill it down to a simple example and ask more specific 

More information about the Twisted-Python mailing list