duanquan1243 2011-07-23 19:23
浏览 102
已采纳

PHP AJAX多人游戏

I'm planning a relatively simple, online, multiplayer game and I'm stumped on what to use for player to player communication.

Game details:

  • 6 Players
  • Chat box
  • 30 second rounds (intermissions)
  • Time sync is important

Players select and action and at the end of the round, the action is performed, there is a brief intermission to detail actions and a new round begins.

I've determined to build this game entirely in JS and PHP (of course AJAX). I just don't know what I should use for the client to client communication - I initially planned on using constant 1/2 second AJAX calls to the PHP script using mySQL to store the game/user data, but I'm afraid that will be too slow and unpredictable.

I considered using something like a XML instead of mySQL and using something like the php fopen() function - what do you guys think about that?

I read in this question here, where the poster is considering using XMPP, could that be a good solution?

Should I go for a socket? Is that necessary for a game that doesn't require all that much data to be exchanged? What would be required to get this going?

Any suggestions on syncing the round time? Or is this something that I even really need to concern myself with?

I'm open to all suggestions and really appreciate any help I can get.

  • 写回答

3条回答 默认 最新

  • dpg98445 2011-07-23 22:59
    关注

    Go for Comet, you don't need sockets. Comet is a kind of reverse-AJAX. Works perfectly for p2p things like instant messenger, for example, because it pushes data to browser without browser needing to constantly poll the server. And there are many implementations for Comet in JS/PHP, just Google that. Then, as a backend, you could use MySQL or XML or whatever you want (but I would consider MySQL as a better solution, because XML is just a text file which needs to be opened, read, written and closed and the database is designed to be faster than that).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘