After studying python network libs, I made this template (still work in progress !!).
This demo is already a fully functional example of a networked multiplayer game (using server X thin client architecture).
A brief explanation of the architecture is here
This demo is a 3D Pong, where two players can be at diferent computers in the internet
How to test in one machine:
- Open and run the server first. It will start listening two connections. Blender will freeze because this is a blocking operation. Let it opened. (Multi-threading python is causing Blender crash in my machine)
- Open another Blender with the client and run it. This Blender will connect via TCP to the Blender server. Again, this new Blender will freeze because we need to wait the second client/player to start the game (this synchronization is done by blocking TCP reads)
- Open a third Blender with the client. When you run it, this third Bender will connect to the server and the game begins !!! Try to put the windows side-by-side to see the fast syncrhonization achieved using UDP messages
- Use W, S, A, D keys in the two clients to see how the state is spawned to server and the clients. Ball physics is spawned automatically !
For now, to test in networked machines you need to change the IP adresses in the scripts. Remember to always start the server first ! The network protocol is the python serialization function in the module “pickle”.
To python prgrammers: Discover how one client can “cheat” the server in this example
I’ll try a tutorial on this when completed.
UPDATED: Server now tracks score and clients are textured and has shadows. Now I’ll try to make multi-threading connection works