JavaScript 有多人棋盘游戏框架吗?
我可能会使用 javascript 开发在线棋盘/纸牌游戏。 我的方法是让客户端能够在独立模式下工作,因此它必须执行规则。这意味着,例如,如果玩家不能打出一张牌,他或她甚至不应该打出它。这是为了增强用户体验。
这里的想法是添加钩子来向服务器发送和接收事件,并在服务器和客户端之间共享实现游戏规则的代码。我不认为写两次有什么意义。
因此,如果我在“服务器”模式下玩,客户端将使用我的操作更新服务器(也验证它们),并且服务器将向我发送有关其余玩家的更新。
是否有任何框架可以利用这项工作?
对于服务器端,我的选择似乎是 Node.js(不稳定,但一切都是 JS,这很简洁),Erlang + erlang_js,也许还有一些“编译成 javascript”的奇怪框架,我真的不是喜欢.
I will probably use javascript to develop an online board/card game.
My approach will be to have a client that will be able to work in standalone mode, so it must enforce rules. That means for example, if a player can't play a card, he or she shouldn't even be able to play it. This is to enhance the user experience.
The idea here is to add hooks to send and receive events to and from the server, and share the code that implements the game rules between the server and the client. I don't see the point of writing them twice.
So, if I play in "server" mode, the client will update the server with my actions (verifying them as well), and the server will send me updates about the rest of the players.
Is there any framework to leverage this work?
For the server side, my options seem to be Node.js (unstable, but everything would be JS and that's neat), Erlang + erlang_js, and maybe some of those weird frameworks that "compile into javascript", that I'm no really fond of.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来 Ape 非常符合您的要求。它支持 javascript 模块,因此您可以在服务器上运行与客户端相同的代码,并且很好地支持在不同用户之间发送消息(查看 MMORPG 和聊天演示)。
Sounds like Ape fits your requirements rather closely. It supports javascript modules so you can run the same code on the server as you use for clients and sending messages between different users is well supported (check out the mmorpg and chat demos).
我已经使用 RingoJs http://ringojs.org 来实现这一点 - 客户端和服务器代码共享 - 一段时间了。
为了更轻松地编写网络浏览器游戏,我在其上开发了一个薄层: http://gamejs.org
I've been using RingoJs http://ringojs.org for exactly this - client&server code sharing - for a while.
For writing networked browser games easier i'm developing a thin layer on top of that: http://gamejs.org