Creating a 2 player game in Python

喜欢而已 提交于 2019-12-06 05:59:06
Erik Kaplun

I would suggest starting out by making a non-networked version of the game that supports 2 players in the same program instance/window. This way you'll be able to re-model/design your code to support 2 players in the first place.

If that's working, you have to choose a networking library to use (or raw TCP/sockets), think about the problem a little bit, and refactor/split the program in such way that you can separate the 2 players into 2 separate programs communicating with each other over network.

For networking, RPC (Remote Procedure Call) is probably the easiest to use choice for you; for options, check out: What is the current choice for doing RPC in Python?. Or you might just want to go with something very primitive such as socket, or a bit less primitive such as ZeroMQ.

You might also be interested in this: http://pygnetic.readthedocs.org/en/latest/:

pygnetic is a library designed to help in the development of network games and applications in Pygame

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!