A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: tile game code example

  1. #1
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244

    tile game code example

    This message is just to point you to the thread with a code example.

    I worked out pretty simple code for a basis of tile type games.
    Example, and source code included.

    Read the thread:
    http://www.flashkit.com/board/showth...hreadid=425609

  2. #2
    Member
    Join Date
    Nov 2001
    Posts
    49

    multiplayer tile game & PHP?

    Love the example,
    I'm wondering if its possible to add multiplayer functionality to this type of game using PHP & MySQL?
    if not multiplayer in real time, what about a 1 player mode & saving the score for comparison among other players, that would be simple I'd think.

    Im ok W/php & could write the script needed for the latter suggestion but lost when it comes to integrating with 3dfa.

    any ideas? sorry if this has already been covered.

    Thanks,
    Jerry

  3. #3
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Short answer is Yes you could but would be a bit tricky and awkward as this is not where PHP is very good. Perhaps Kusco would care to jump in (he's back I understand) he was working on doing a real time multiplayer concept a while back.

  4. #4
    Senior Member kusco's Avatar
    Join Date
    Nov 2001
    Posts
    681

    A little tricky....

    Hello goodwin2 and blanius,

    My ears were burning and I knew there was only one place where I could find the cause

    Multiplayer games (I'm assuming on different computers across the Internet) can be achieved in one of 3 different ways.
    [list=1][*]e-mail
    When a player makes there move the details of the move are stored away in a database. The opponent/s are then notified by email of the move and it then becomes their turn.[*]push and pop
    Once again a database is used to store the details of the move but this time your opponent is checking to see if you have made a move by regularly quizzing the database. When you make your move the opponent is then permitted to make there move.
    This technique can also involve more than two players and doesn't necessarily have to be tied down to a single move at a time. Indeed, you can create a multimove/multiplayer game this way.
    There is a serious downside to doing this and that is the database will become bogged down with requests to see if an opponent has made a move. Consider a chess game where you can have as many as 100 different games being played at once. This equates to 200 players and each one is checking to see if the opponent has made a move. If the check is done only once every second then that is 100 quizzes to the database every second.[*]Telnet
    This is an area that I know little about (for the moment) but I've been informed that it's not too difficult to achieve. The advantage of using Telnet is that you don't have to wait for your opponent to make a move and there is no need to continually access a database. When a move is made the information is sent to the other computer in a single telnet packet. Both computers need to connect through telnet and then the software has to be able to deal with the packets coming in and out of the computer. This is far beyond my knowledge at this stage.[/list=1]
    Now to answer the question:
    Yes, I've been busy with a multiplayer game. Yes, it's tricky to set up the code to check for a move but it's most definately possible.
    The way that I do it is very similar to the way in which blanius' guestbook (from memory) checks for new data.

    What we do is 'open' a url, which in fact is a request to a database for information, and we wait in a loop until the information has been sent back from the database. This is a fairly simple idea and works well. This technique is really point 2 from above and therefore has that problem with the issue of database access where you may end up bogging the database down with too many requests for information.

    I believe that MySQL would be a far better choice of database access for this method of multiplayer games. Coldfusion tends to be a bit too slow and is good for small numbers of enquiries. MS-SQL ... well, it's really good at some things but Microsoft has a tendancy to bloat a request for information and in turn slows it down again. However it is still faster than Coldfusion. MySQL outperforms any other database and all the stats I've seen on it have left me in no doubt to this. I've seen it in action and it's just mind blowing. I'm not trying to plug MySQL (which is freely available for download and works really well with PHP) but I feel that it should be given a fair go (and it's also available for unix, Linux and Win32 platforms).

    Now how do we go about doing it? Good question. I personally use Coldfusion for the moment until I get the time to install MySQL and PHP on my servers at home. But if you're familiar with writing cgi's then it should be a breeze.

    There have already been a number of threads that cover this topic on how to retrieve information from a url and load it into a movie.
    I'm not sure if blanius has posted the source to his movie that checks for the presence of data being returned from a database.
    May I first suggest searching the forum for loading variables. If you are not able to find the threads then I will put something together as an example but it won't involve the use of a database instead, it'll simply be to show how to retrieve information from another page (which in effect is the same as retrieving it from a database).

    Using the 'OpenURL' in 3dfa is good for only sending data to a cgi. It's also possible to use the 'Flash Command' as well which I have used in the past but I have primarily used this to get the browser to retrieve date/time information from the local pc. 'Load variables' is the other method I've used to send/retrieve data and this I feel is the better method to use.

    (I would have posted this yesterday except the Flash-Kit forum was down for quite a while)
    Cheers,
    kusco
    (3DFA Support Team)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center