PDA

View Full Version : [AS3] Multiplayer game help


The Little Guy
07-03-2009, 01:31 AM
Im not sure if this is the correct place for this, because this is more of a design question.

I am making my first multi-player game, one that uses two computers and the internet, not two people at one computer type of multi-player game.

So, I assume everyone knows how to play tic-tac-toe (if not: http://en.wikipedia.org/wiki/Tic-Tac-Toe). So my question is what would be a good way to randomly assign one player X and the other one O?

I am not sure if anyone knows how a php flash communication server works, so I'll explain it:
- First a user connects
- The server sends flash the privacy file allowing it to connect
- Flash then reconnects to the server after a successful connection
- Flash waits until the server sends something to it
- The server receives information then sends it to everyone else that is connected

Doing this you could potentially have chat server, game server, etc.

I don't want to have to modify the php to handle the X's and O's I would like that to be done via flash, so the flash would have to check if anyone is playing if some one is playing, then check what player the other player is (X or O) and assign him/her the opposite of that.

If there is no one playing, then randomly assign the current player X or O.

Anyone know how I could tackle this?

abeall
07-03-2009, 06:16 AM
I don't really follow what you are using on the backend to manage the connection of the players. Are you using a socket server built in PHP? In any case, you have two options as I see it:

1. You need a server app. The server app assigns X and O to two connected players.

2. One of the SWFs becomes a master, and that SWF basically replaces the server app. Keep in mind that this is easily hackable because you are giving authority to the client.

The Little Guy
07-03-2009, 05:59 PM
I don't really follow what you are using on the backend to manage the connection of the players. Are you using a socket server built in PHP?

Yes.

So... You reccomend having the server do all work, such as:

- choose who's turn it is
- choose who starts
- choose who won
- choose who lost
- etc.

If I were to do it that way, how would I then be able to make multiple games like this ex: checkers, connect four, mmorpg, etc.?

bluemagica
07-03-2009, 06:46 PM
Just play the game on server and get input and output on client! I don't see whats so hard about that.... everything is just a bunch of calculations, whether its a pong or a MMORPG, so just do that on the server, where the players have no direct way of fiddling with it!

Oh, and what's with the "privacy file", don't you mean a policy file? And what type of server are you using? php based socket server? xml sockets? java server? or what?

The Little Guy
07-03-2009, 07:42 PM
Oh, and what's with the "privacy file", don't you mean a policy file? And what type of server are you using? php based socket server? xml sockets? java server? or what?

Yes, a policy file, sorry.

I am using a PHP Socket server.

So, lets say I wan't to make more than one game, does that mean I will have to make a server for each one?

bluemagica
07-03-2009, 08:07 PM
Well php is fairly object oriented in its basics now, so if you keep your game logic separate from your server logic, you can just extend a core server!

abeall
07-03-2009, 08:15 PM
I am using a PHP Socket server.

So, lets say I wan't to make more than one game, does that mean I will have to make a server for each one?

Are you custom developing this PHP socket server? You definitely shouldn't need multiple server instances running to have multiple games going on at once. The server should be able to take connections and manage some type of room/game listing which it can pair up players in, or players can choose a game to join or start a new game, etc. The server can then loop through all active games and update as needed.