Pygame 的网络支持
我正在 pygame 中制作一个简单的多人经济游戏。 它由一定长度的轮组成,在轮的末端,数据被发送到中央服务器。 对数据进行一些快速计算,并将结果发送回玩家。 我的问题是我应该如何实现网络支持。 我一直在关注 Twisted 和 Pyro,如有任何建议或建议,我将不胜感激。
I am making a simple multiplayer economic game in pygame. It consists of turns of a certain length, at the end of which, data is sent to the central server. A few quick calculations are done on the data and the results are sent back to the players. My question is how I should implement the network support. I was looking at Twisted and at Pyro and any suggestions or advice would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
pygame.org 网站上有许多专门为与 PyGame 良好配合而定制的即插即用库。
其中包括 PodSixNet、PygLibs.net 和我自己的 Mastermind(冒着自我夸大的风险,轻量级、易于使用,并附带一个简单的教程)。
There are a number of plug-and-play libraries tailored specifically to work nicely with PyGame on the pygame.org website.
These include PodSixNet, PygLibs.net, and my own Mastermind (which is, at the risk of self-aggrandizement, lightweight, easy to use, and comes with a simple tutorial).
我并不反对 Twisted 和 PyRo,但是您要发送的那种简单消息不需要类似的东西,并且使用某种框架可能会变得过于复杂。 Pickle 一个对象并通过套接字发送它实际上是一个非常简单的操作,非常值得尝试,即使您最终使用更重量级的框架。 不要害怕网络!
I've nothing against Twisted and PyRo, but the sort of simple messages you're going to be sending don't require anything like that and might be overcomplicated by using some sort of framework. Pickling an object and sending it over a socket is actually a very easy operation and well worth trying, even if you do eventually go with a more heavyweight framework. Don't fear the network!
扭曲肯定是个好主意。 这里是集成twisted和pygame的示例代码。
Twisted would certainly be a good idea. Here is example code that integrates twisted and pygame.