[Twisted-Python] how to handle game messaging
Hello, I'm new to the list. I've been going through the twisted tutorials, and now I'm trying to write a simple asteroids clone to better understand twisted. ( Think asteroids: but 2 players on a LAN ) (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 ? (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? (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. Here's an overview of the code: A GameClient() (run once per client) and GameServer() (run once). There is a list of Bullet()s and a list of Asteroid()s. When a player fires, he will tell/ask the server. The server will pass all spawnings onto the clients. I don't think I need to constantly update the clients with physics updates -- except the locations of the players. All other updates should be able to be handled on events ( asteroid shot, player collisions, etc... ) thanks, -- Jake
On 01:57 pm, ninmonkeys@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: http://twistedmatrix.com/documents/current/api/twisted.protocols.amp.html 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 questions.
participants (2)
-
glyph@divmod.com -
Jake b