views:

832

answers:

4

I want to build a multiplayer online boardgame like monopoly using php, mysql. I want to run the game in the browser. Multiple people connect to the game, then each person takes turn rolling the die, making trades etc...

I was curious how other game developers achieve the "turn base" functionality in real-time. Does the client browser have a javascript timer that periodically fires an AJAX call to the webserver for updated game board information? That seems rather inefficient.

What should I research before I begin my project?

+2  A: 

For an mvc php web framework, try http://www.cakephp.org/

If you want to make your game run natively in a browser and have it work on all major browsers (ie, firefox safari), then some sort ajax polling is needed without having to do serious workarounds. If you don't want to do polling, you may want to look into 'comet' programming methods (http://en.wikipedia.org/wiki/Comet_(programming)) . However, I don't know of any mature methods which work across all browsers.

If you still want your game to be in a browser, then you can try browser plugins like flash or java, which won't necessarily tie you to the limitations of http.

Last piece of advice if you use ajax: build your game without ajax first. Ajax is a lot easier to add once you've done everything else.

mweiss
A: 

So many opportunities. :)

But basically you want to use ajax to let the clients make a turn and so on. I recommend using a JavaScript framework like jQuery and Prototype. You can find some great tutorials out there, like this: Prototype: Introduction to Ajax.

And then you have to make the server handle the clients requests and make the game work. That's gonna take some time. Make sure you have all your game rules ready before you begin.

So you can research basic JavaScript and learn a JavaScript framework, and of course PHP and MySQL. That's a good start.

A: 

Using plain javascript it's impossible for the server to initiate comunication with the client. You'll need to use poling or use a different technology.

You could only transmit what changed in the game, and not the entire game state. Simply send a version number in every game state data package and yor client will know what to do (update the screen or ask for more information). You will spend far less resources in general this way.

Morgaelyn
+1  A: 

My suggestion would be to ignore the technology for now and instead focus on the boardgame aspect.

Your mention of Monopoly suggests you may not be up to date with the latest trends in boardgaming and boardgame design. You may want to check out link text and link text .

Thanks, great to meet another fellow board gamer! Yeah, I stated monopoly as an example because it's well known. But really, i want to do a variation on "Ticket to Ride".
John