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

Friday, March 10, 2006

Hi. I promised to explain how everything fits together in my Scramble game. By the way, it has been improved thanks to a good friend of mine, Charlie, who tests my games and points out that instructions are usually a good thing.
What the Flash does for each player is send the move to the server like this (this is for player 1):
myCommunications.fnMessageSuccess = function ()
    {gotoAndPlay("Player1TestMessageID");}
myCommunications.fnMessageFail = function ()
    {trace ("fail activated");gotoAndPlay("Player1End") }
myCommunications.fnSendToServer (1) ;
Then it tests the message returned is correct.
if (parseInt(myCommunications.gmyLoadVars.messageID) != 1 + 
myCommunications.gnMessageID) {
    trace(["MessageID Error",
    myCommunications.gmyLoadVars.messageID,
    myCommunications.gnMessageID])
    _level0.gotoAndStop("ConnectionError")   
}
Lastly it repeatedly asks the server (every 3 seconds) if the opponent has made his move.
if (parseInt(myCommunications.gmyLoadVars.messageID) != 1 + 
myCommunications.gnMessageID) {
    trace(["MessageID Error",
    myCommunications.gmyLoadVars.messageID,
    myCommunications.gnMessageID])
    _level0.gotoAndStop("ConnectionError")   
}
myCommunications.fnMessageSuccess = function () {
    if (parseInt(myCommunications.gmyLoadVars.pno) == 2) {
        gotoAndPlay("Player1LoopEnd");
    }
}
myCommunications.fnMessageFail = function ()
    {trace ("fail activated");gotoAndPlay("Player1Loop") }
myCommunications.fnLoadVariables("?action=VIEW&filename=" + myScrambleGame.gnGameNumber);

This concludes the explanation, but if you feel I missed a bit (or a lot) out, please comment or email me. My next task is to convert 3 more games to running over the net, and I will blog if I have any improvements.

# posted by nicolas_evans @ 12:57 PM
Comments: Post a Comment




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