Welcome

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.

The Posts

Wednesday, July 26, 2006

Hi. One of my goals has to write multiplayer games that update in real-time, that is the server pushes information, rather than the client pulls it by polling every few seconds. Basically a socket server. My investigations have not found a way to do this that is both simple and cheap. So instead I shall be concentrating on moving away from the alternate turn model, and towards progressive updates of the board. But still using the polling server method. I shall let you know my progress.

# posted by nicolas_evans @ 7:59 PM  

The Posts

Wednesday, June 28, 2006

Hi. Sorry there have been no posts recently. I have been busy finishing my website “Of Time and the River” for the end of July. Hope to go back to multiplayer games after that.

# posted by nicolas_evans @ 7:28 AM  

The Posts

Monday, May 22, 2006

Hi. I have now finished Fish Or Foul, you can find it in the links. I found another gotcha.You cannot rely on a movieclip to set a property via gotoAndPlay, if you need to access that property in the current frame.

# posted by nicolas_evans @ 7:46 AM  

The Posts

Thursday, May 18, 2006

Hi. Still working on converting Fish Or Foul. The most difficult game I have converted, mostly due to it being an older game. I have learnt to include all necessary movieclips in the constructor and not to rename movieclips. I also encountered a gotcha, where the class owning a static function cannot access that function. This only happens in the Flash Player 6, it works correctly in Flash Player 7.

# posted by nicolas_evans @ 8:59 AM  

The Posts

Friday, May 12, 2006

Hi. I have finished Mammoths. I am now working on another game, Fish or Foul. In this game, players take two turns in a row. So new problems to make this one work.

# posted by nicolas_evans @ 1:16 PM  

The Posts

Wednesday, April 26, 2006

Hi. I am busy working on my third conversion, Mammoths. You can find it in the links, as its easier keeping those up to date than the posts. Am finding it a lot easier to convert a game now. However I did run into one issue - its not obvious which piece the opponent moved. So I added a shading movieclip with an alpha of 20 percent for the route moved. Here is the code:
// 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)

# posted by nicolas_evans @ 10:35 AM  

The Posts

Friday, April 21, 2006

Hi. I finished converting another game to play over the internet, Navvy. You can find it in the Links section. I have moved to paid hosting on Godaddy (www.godaddy.com), so this meant using php for the backend. This is the code, apologies as this is my first php program:
<?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;
 }
?>

# posted by nicolas_evans @ 9:06 AM  

This page is powered by Blogger. Isn't yours?