View Full Version : MMO-game : PHP vs AS2
Danneman
May 23rd, 2004, 12:34 PM
Ive been working on a virtual chat-room where you walk around with your avatar.
After having created a class (in AS2) that takes care of the creation of all the avatars, I also included the code for how they should navigate.
Since it is a click-n-walk type of game, this navigation-code becomes pretty big.
But now I figure I should probably have coded a navigation-function in PHP instead, that all the different avatars can call.
What course do you take when implementing the navigation-code in a MMO? What parts should be programmed in AS, and what parts should be programmed in PHP?
Marz
May 27th, 2004, 01:58 AM
Everything that has to do with actions should be programmed in AS. Everything that needs to sent over via the net to other players should be done via PHP.
So.. PHP should handle that.. Whenever a person clicks a certain tile. it sends information out to let everyone know that you are moving to a specific location.. that specific tile. Then it will gather that information and make that character move. this is where AS comes in. Making the character move as per commands issued by yourself.
Danneman
May 31st, 2004, 05:33 AM
Thanks for the reply, Marz.
Let me see if I have understood correctly.
So far Ive made a working single-player game made up in AS (chat-function, automatic mapgeneration, movement with pathfinding, etc).
Ive got a couple of classes for the major stuff - MAP, TILEs, AVATARs, CHAT, GAME, etc.
The AVATAR-class contains the pathfinding-algoritm (very simple to keep it fast), so when you click on a tile, that tile calls the move-function of the avatar-instance in question, and sends its own coordinates as parameters with that call. Then the avatars move-function calculates the path, and walks there.
So heres what I thought Id do when turning this thing into a multiplayer game: just let the tile pressed send a move-function call (with the coordinates as parameters) to every client through the server, and then each clients computer would have to calculate the path by themselves in AS, and move the avatar corrispondingly.
What Im concerned about is that there will be a discrepancy between the path calculated by one computer (client), compared to the path calculated by another (due to lag, etc). Thats why I figured that perhaps it would be best to have the actual pathfinding-algoritm in PHP, which would guarantee an identical path calculated for the avatar on each clients computer.
So, should path-finding be considered an "action" and be placed in AS for each client to calculate by themselves? Or should it be pre-calculated by PHP on the server, and then distributed to each client?
Marz
June 1st, 2004, 09:42 PM
It all depends man. You could send over additional data to make sure that the path is correctly followed by both computers or you could just make a slightly more adavcned pathfinding algorithm that has about 99.9% accuracy with judging the distances and which way to go.
Now, there will be times when that would be a problem.. But since it is tile based.. You could always send an array of datapoints that would clarrify which way "exactly" the avatar will travel.
Danneman
June 2nd, 2004, 03:43 AM
Great ideas, man!
Perhaps Ill just make another, simpler version of the move-function, in addition to the move-function that includes path-finding.
Then only one client has to do the pathfinding, and for each step it takes, it sends out function-calls to the simple move-function (to all the other clients), which just takes them to the location calculated by the original client.
Its pretty fun just to experiment with all this :D Gives you a whole new (albeit flawed) understanding of how MMORPGs works, for instance.
Btw, Im wondering if you know a good way to execute code sequentally?
I have a problem with the constructor of my map-generating class.
Its supposed to execute a piece of code FIRST (generating instances of the TILE-class), and only after that is complete, execute the next piece of code (setting values to the generated tiles).
But it never works out that way - the second piece of code always starts way before the first piece of code has finished executing. Screws everything up.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.