简体   繁体   English

本地局域网多人游戏中转Python游戏

[英]Turn Python Game in local lan multiplayer game

i make a game called "Pong" in python and turtle(module) and i want to make it a local LAN multiplayer game.我在 python 和海龟(模块)中制作了一个名为“Pong”的游戏,我想让它成为本地局域网多人游戏。

can someone tell me how can i do it.有人可以告诉我我该怎么做。

i want to make it a local host like game so that me and my brother can play.我想让它成为一个像本地主机一样的游戏,以便我和我的兄弟可以玩。

You'll achieve this by using sockets.您将通过使用 sockets 来实现此目的。

As a start, you'll need to make a Server script which will handle the game events.首先,您需要制作一个Server脚本来处理游戏事件。 Also, you'll need a client script that will display the game to the player & take the user's input + send them to the Server.此外,您需要一个client脚本,将游戏显示给玩家并获取用户的输入并将它们发送到服务器。 The server will be responsible for the synchronization of the game in both clients.服务器将负责两个客户端中的游戏同步。 You can run the server script in your PC then connect using the client script from both computers to the server.您可以在 PC 中运行服务器脚本,然后使用客户端脚本从两台计算机连接到服务器。

Here is a link ("What every programmer needs to know about Game Networking") for further details.这是一个链接(“每个程序员需要了解的关于游戏网络的知识”)以获取更多详细信息。

EDIT: I found this tutorial to create a simple 2-player game using PyGame and PodSixNet .编辑:我发现教程使用PyGamePodSixNet创建一个简单的 2 人游戏。 The first part is creating the Client side of the game.第一部分是创建游戏的客户端。 The second part is creating the Server side & adding the game logic.第二部分是创建服务器端并添加游戏逻辑。 It may be a good start if you're interested.如果您有兴趣,这可能是一个好的开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM