douhuan2101 2012-06-06 18:53
浏览 75

与PHP的多人游戏。 我有什么机会? [关闭]

Firstly, I would need this information to make a realtime multiplayer browser game. Right now, I can pretty much code everything, with an exception - serverside events has to be pushed to clients. So I need a real solution (unlike longpolling) on this.

I've been reading all the forums, all the articles, but this is confusing me.

I would like to ask some questions, but I need an indepth reply, if possible.

  1. HTML5 brought us the WebSockets feature. It was barely supported by browsers at first, but right now, pretty much all up-to-date browsers supports it. Is it going to be the comet solution of future? Can it kill node.js and other solutions?

  2. There are so many options to pick from. Node.js, socket.io, APE, using API's of 3rd party websites. (like pusher.com) What would be the most benefical for me? I want to code server-side with PHP. I believe if we use node.js, I should code server-side with javascript too. Is it correct? If not, how can I use PHP with these frameworks?

  3. I am going to code a multiplayer game, so performance/scalability is an essential. I don't think I will ever get more than 100 concurrent players at the start, but nobody knows what future brings, so I would like it to code the way it can support few thousands of concurrent players in the future. What are my options?

  4. PHP, as much as I like the language itself, it simply lacks in this area... I don't want to code games like Travian, they're boring. I would like them to be realtime. I can learn a new language for this task if necessary. What's your opinions about this?

  5. I'm currently using Apache as a local web server. Used IIS and Nginx in the past. Is there any PHP web servers designed for this job? As far as I know, some languages had special web servers designed for concurrency. (e.g Tornado Web)

Setting max_execution_time to 0 and flushing new data to clients in an endless loop is not an option in this case, it is not even effective at all.

Any answer is much appreciated.

Thank you.

Ps. I will use it for other things like realtime notifications too, but mostly my 2D game itself.

  • 写回答

1条回答 默认 最新

  • duanan2732 2012-06-06 19:02
    关注

    PHP is not designed for this. I suggest you pick a language that is designed for this type of application.

    To answer your questions:

    1. The idea of web sockets is to write a game client that can interface with a game server. If you are looking to build a game that uses sockets, PHP will not fit this mold. You need something that will run continuously and most likely be multi-threaded. You are looking at C#, C++, Java, etc. It will not will node.js because node.js is a server. In a browser you are writing a client.

    2. I'm not sure how to respond to this because node.js != PHP. node.js is designed to be a web server. This means that the server takes web requests and sends back the proper response (think like Apache's HTTPD). PHP is a scripting language that interfaces with apache to be able to do more dynamic html processing.

    3. Use C++, Java, C#, etc

    4. Learn C++, Java, C#, or any other language that supports sockets.

    5. No, a web server is suppose to accept a request, process it, and return the result. If you are looking for continuous communication between a client and a server, a web server is not what you are looking for.

    There are products out there that already take care of a lot of the ground work. I recommend you look at something like Photon or Smart Fox Server

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog