View Single Post
Old 03-29-2007, 05:41 PM   #3 (permalink)
Vormund
 
Monster Techie

Join Date: May 2004

Location: Tucson, AZ, USA

Posts: 1,183

Vormund

Send a message via AIM to Vormund Send a message via MSN to Vormund Send a message via Yahoo to Vormund
Default Re: PHP 2-player game?

One thing to note is that PHP is server-side...hence you're either going to be reloading the page each time, or using some javascript AJAX.

Using just PHP, the only way this would be possible is by setting a refresh timer on the page (refresh every x seconds), and storing values (either in a file or database) as to who's turn it is, then updating the "fields" accordingly.

The bottom line is...you need to decide what this game will be, if PHP is really what you want, and how you plan on storing data (in a file, mysql db [best], or an alternate method)... the logic being along the lines of:

1. User logs in, the session is set. Page refreshes every 5 seconds.
2. MySQL table has flags for the user's - if they're playing and who they're playing, and another to determine who's turn it is.
3. Then you might have another table with a unique game ID which those players are using, which would represent your "fields", and you would draw the HTML output based on any values stored here.

Definitely not ideal for a real game, but it'd be a good learning experience and likely good enough for your class (I assume)!

PS: I dare you to make a Chess application like this!
__________________
Vormund is offline