View Full Version : 2 player game

06-03-2001, 05:11 PM
I am creating a two player game (2 different computers), and when a player makes a move, I need the other player to see it. I am thinking of using php and/or mysql.

Can php do it alone, or do I need a database?

Also, does anyone know of a tutorial or example of this?


06-04-2001, 01:23 AM
Yes PHP can do it alone. From my limited experience I think XML would be the best way to do this actually as it seems to be what everyone uses for such purposes. Back int he days of Flash 4 I made 2 player chess which wrote each move to a text file and then looped, reloading the text file. That was done with PHP. Checkout FlashGuru's latest fling - a chat and draw program for multiple clients which uses XML. http://www.actionscripts.org/forums/showthread.php3?threadid=2390

06-04-2001, 11:25 AM
Thanks, I downloaded the swf. I'll check it out and do some research on the xmlsocket idea.

In the chess game that you made, how did other users see it? I thought if you just used PHP that only the one user would see the change. Simple explanation?


06-05-2001, 01:12 AM
I updated an interim data file on the server which sotred the information needed to replicate a move on the other client - which piece, from where, to where, any captures?

you can still see it in it's buggy form at http://flashchess.cjb.net

06-05-2001, 01:45 AM
Nice work! That's basically what I want to do, except I have mc's that change frames instead of moving pieces to different squares. Until I get a good grasp on xml, could you give me a hint using php with text. How do you update the other users' movie? Have it call the text page every few seconds? Any hints are appreciated. Thanks again.


06-05-2001, 01:50 AM
if you enter your session number followed by a move number and .txt yuo will see the data I'm storing. So if your session is "jesse" enter: flashchess.cjb.net/jesse1.txt (that should work - after you've moved of course)

if you do a search here on "write text file php" there's heaps of threads with almost the exact source I used to create the text files. I then make the players wait using a 20 frame loops (this was flash 4 remmeber so no time options really) and check at the start of each loop if the variables are loaded yet, if not, keep looping.

also note players are not allowed to move while this loop is going on as it would confuse the game.