简体   繁体   English

在两台电脑上运行游戏?

[英]Run a game on two computers?

I am creating a two-sided war game using Greenfoot.我正在使用 Greenfoot 创建一个双面战争游戏。 I would like to play it with my brother but I would also like my brother to be able to see only one part of the whole map and me too.我想和我的兄弟一起玩,但我也希望我的兄弟只能看到整个地图的一部分,我也一样。 Hence, I would like my brother to be able to play it on his computer and I to play it on mine.因此,我希望我的兄弟能够在他的电脑上播放它,而我在我的电脑上播放它。

This is supposed to be a real-time game but I could make it turn-based if it's too hard.这应该是一个实时游戏,但如果太难,我可以让它变成回合制游戏。 How do I connect my mac and my brother's mac so that the game runs simultaneously on both ( I would like it to receive both keyboards input).如何连接我的 mac 和我兄弟的 mac 以便游戏同时在两者上运行(我希望它接收两个键盘输入)。

I have no experience in networking so I don't know if it's possible.我没有网络经验,所以我不知道是否可能。

This communication between your mac and your brother mac could be done using java sockets.您的 mac 和您的兄弟 mac 之间的这种通信可以使用 java 套接字来完成。 You will be the server, and your brother will be the client.您将成为服务器,而您的兄弟将成为客户。 You need to open the server with ServerSocket on a specific port and your brother will connect with the help of Socket .您需要在特定端口上使用ServerSocket打开服务器,您的兄弟将在Socket的帮助下连接。 You can find more details about implementing a java socket here ( and look at the 3rd chapter named "Simple Example")您可以在此处找到有关实现 java 套接字的更多详细信息(并查看名为“简单示例”的第 3 章)

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

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