Welcome to my blog. I mainly blog about the basics of running Flash games over the internet, but sometimes I get distracted. Here you will find my efforts at programming turn based Flash games, plus links to all the games I have written. You are free (as in beer) to get all the code, just email me - nicolas_evans at yahoo.com (sorry you cant click on it - I dont want more spam).
Building Multiplayer Games in Flash.
// in the constructor for (i = 0;i<15;i++) { mcCa.attachMovie("McMarker","mcMarker" + i,++gnNextDepth,{_x:-100,_y:-100,_alpha:20}); } // at the start of turn k = 0; i = gnStartI; j = gnStartJ; mcCa["mcMarker" + k]._x = (i - 11) * 40; mcCa["mcMarker" + k]._y = (j - 11) * 40; do { if (i < gnEndI) i++; else if (i > gnEndI) i--; if (j < gnEndJ) j++; else if (j > gnEndJ) j--; k++; mcCa["mcMarker" + k]._x = (i - 11) * 40; mcCa["mcMarker" + k]._y = (j - 11) * 40; } while ((i != gnEndI || j != gnEndJ) && k < 15)
<?php $intVariableCount = 7; $filename = $_GET['filename']; $action = $_GET['action']; if (is_numeric($filename)) {} else die( "v=v&nErrorNumber=" . $intErrorNumber ); if (file_exists("gamefiles/cr" . $filename . ".txt")) {} else { // File does not exist, so create it. $filePointer = fopen("gamefiles/cr" . $filename . ".txt", "w"); fclose($filePointer); } // Check that we have read and write access to the text file. is_readable("gamefiles/cr" . $filename . ".txt") or die("ERROR : Do not have read access to file $filename, consult your server administrator."); is_writeable("gamefiles/cr" . $filename . ".txt") or die("ERROR : Do not have write access to file $filename, consult your server administrator."); // Read the file in $contents = file("gamefiles/cr" . $filename . ".txt"); $maxid = count($contents); for ($i = $maxid; $i < $intVariableCount ; $i++) { $contents[$i] = " "; } // Process the actions // Insert a score/name if ($action=="INSERT") { $intErrorNumber = 0; // Abandon message if not later than the file $contents[0] = $_GET['pno']; if ($contents[0] != 1 && $contents[0] != 2) { $intErrorNumber = 1; } if ($contents[1] + 1 != $_GET['nTurn'] ) { $intErrorNumber = 2; } $contents[1] = $_GET['nTurn']; $contents[2] = $_GET['p1hand']; $contents[3] = $_GET['p2hand']; $contents[4] = $_GET['board']; $contents[5] = $_GET['order']; $contents[6] = $_GET['ltm']; if (is_numeric($_GET['messageID'])) {} else $intErrorNumber = 8; if ($intErrorNumber == 0) { $filePointer = fopen("gamefiles/cr" . $filename . ".txt", "w" ); for ($i=0;$i & lt; $intVariableCount;$i++) { fwrite($filePointer,"$contents[$i]\n" ); } fclose($filePointer); $intTemp = $_GET['messageID'] + 1; echo "v=v&messageID=" . $intTemp; } else { echo "v=v&nErrorNumber=" . $intErrorNumber; } } // Clear the list else if ($action=="CLEAR") { echo "create empty file"; for ($i=0;$i & lt; intVariableCount;$i++) { $contents[i] = " "; } $contents[0] = "2"; // pno $contents[1] = "0"; // nTurn $filePointer = fopen( "gamefiles/cr" . $filename . ".txt", "w" ); for ($i=0;$i < $intVariableCount;$i++) { fwrite($filePointer,"$contents[$i]\n" ); } fclose($filePointer); } else if ($action=="VIEW") { echo "v=v&nErrorNumber=0" ; echo "&pno=" . $contents[0] ; echo "&nTurn=" . $contents[1] ; echo "&p1hand=" . $contents[2] ; echo "&p2hand=" . $contents[3] ; echo "&board=" . $contents[4] ; echo "&order=" . $contents[5] ; echo "<m=" . $contents[6] ; } else { echo "action not recognized" . $action; } ?>