I need to do some basic networking for a Pygame project.
Basically, it\'s a 2D single player or cooperative game. The networking only needs to support 2 players, with on
Using raw sockets is low-level and full of danger. As said before, Twisted is complex and takes to time get up and running. To save yourself some headaches I'd try something like https://github.com/dotcloud/zerorpc-python
You need following solutions:
Above should still be called 'basic', you should really use some fancy networking library with idiomatic API.
UPDATE:
Essentially you need to expose network service (in it's own thread) that will push messages to Python's Queue
, then access this same queue from your Pygame code, and if there is a message then you update whatever structures you use to store player's position and draw it on screen. You shouldn't sent stuff like bullet positions over the network as they can be easily (and faster) calculated locally, you just send an event like bullet_shot
over the network with source position and velocity vector.