开发基于网络的游戏-连接用户 [英] Developing a web based game - connecting users
问题描述
我使用AJAX(井字游戏,连接四个)为单个玩家做了一些非常简单的网页游戏.
现在我想迁移到多人游戏,所以我需要建立某种客户端-服务器连接.
在我的游戏中,我按开始游戏",并且显示正在等待其他玩家加入",但随后我不知道如何处理这种情况.
你能给我一个提示吗?我过去曾经做过一些客户端服务器应用程序,但是对于Web来说肯定是不同的,我只需要知道如何处理.
我看到了聊天中使用的一些解决方案,但我想知道您的意见.我不需要永久保存任何数据,我只希望人们访问我的游戏网页并具有以下两种选择之一:
-如果没有人打开页面开始游戏
-如果已经有人在等待加入游戏
-等等...
根据我所看到的(和想要的),我需要创建一个类似于聊天的系统,在该系统中,用户单击开始"游戏按钮(已经登录)后进入一个房间",然后等待另一个用户.
嗯,我应该创建gameRoom类吗?如何创建房间并为其分配用户?
在此先谢谢您.
I did some very simple web games with AJAX (tic tac toe, connect four), for single player.
Now I want to migrate to multiplayer, so I need to establish some kind of client-server connections.
In my games I press "start game" and it shows "waiting for another player to join", but then I dont know how to approach the situation.
Can you please give me a hint? I did some client server applications in the past, but for web it''s for sure different, I just need to know how to approach.
I saw some solutions used in chat''s but I would like to know your opinions. I dont need to save any data in a persistent way, I just want people access my game webpage and have one of two options:
- start game if nobody is with the page open
- join game if already is someone waiting
- and so on...
From what I saw (and want) I need to create a system similar to chats where users goes to a "room" after clicking start game button (being already logged in) and waits for another user.
hummm should I create gameRoom class? How do I create rooms and assign users to it?
Thanks in advance.
推荐答案
所以您应该检查一下此链接;它与您所需要的完全相同:
tic-tac-toe-multiplayer/ [在一小时内将多人游戏功能融入您的游戏中 [ MSDN套接字 [
So you should check this link out; it is identical to what you need:
tic-tac-toe-multiplayer/[^]
Further Info to adapt multiplayer capability;
Building Multiplayer Capability into Your Game in One Hour[^]
I think your key to accomplish this will be using;
System.Net.Sockets class. Have a look at it:
MSDN Sockets[^]
这篇关于开发基于网络的游戏-连接用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!