Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement a multiplayer browser game?

Specifically, how to implement the multiplayer portion? I've been toying around with checkers to exercise my JS/PHP/AJAX muscles and have it working pretty well for one person (or two people on the same computer). But I'm kind of getting stumped when it comes to making it work between two people on two different computers. I have the AJAX portion down, and the server is receiving/sending moves from/to the browser. I just can't wrap my head around what I need to do next to incorporate a second player.

Do I need MySQL for something as simple as this? Can I use some combination of the players' session IDs to just transmit the moves back and forth, rather than storing any info server-side? How does a game session even get started between these two independent entities?

Sorry if this question is ignorant, but I'm just really unsure on how to proceed from this point.

Edit: Just to clarify, there's definitely a server involved (hence the PHP/AJAX references). This much is obvious to me. A "move" will obviously require a trip from player A to the server, then to player B. It's the how that I'm drawing a blank on. Having said that, there seem to be some good answers below and I'll investigate each of them in turn. But feel free to keep adding possible suggestions/solutions as I've already learned a lot just from basic research into the answers already posted.

like image 493
ggutenberg Avatar asked Nov 15 '22 05:11

ggutenberg


1 Answers

I'd recommend going with Comet.

like image 128
Jorge Guberte Avatar answered Nov 17 '22 06:11

Jorge Guberte