PDA

View Full Version : [AS3] PvP Game


Ciubhran
02-27-2009, 12:20 AM
I want to implement a game where two people face eachother in a duel, and the game (swf) updates the other players position and actions on the players side.

So in short, an online game where two players can battle eachother.

What is needed to make this work?

I understand Sockets will be used, but how do you sync the two players. The game shouldnt start until before players are connected to eachother (or something else) and are ready.

EightySeven
02-27-2009, 02:46 AM
A little barbaric but...
Player 1 connect server responds with "only 1"
Player 2 connect sever responds with "Good to go"
Player 1 and 2 move on screen and the client sends info to server
Server then sends the updated info back to the clients to show the players move

bluemagica
02-27-2009, 03:06 AM
lol nice explanation....

I myself am also trying to learn multiplayer at this moment, so i can't help much, but basically synching is done by the server.....the game is actually played(calculated) on the server and the result is sent to the client.

Assume a chat app, where the messages have a special format, like instead of saying, "hi go there", it says "x:20,y:56" , and you can parse that message to make something happen in your game world! But keep in mind there is a bit of delay between the message exchanges, so if both client and server acts on messages, client might try to punch and get a hit, while server has already blocked the punch with a kick (parallel dimensions?).....thats why, in these cases, everything is calculated on server and not client!

Also another thing should be kept in mind, variables that change often like x,y coords, should not be sent too frequently, or there would be huge lag! And when sending them, in realtime games, UDP is better than TCP! (TCP is more secure and stable, but slower)

EightySeven
02-27-2009, 03:33 PM
which is why you should use a tweenTo type function your client xy, the server xy update and then move between the 2

alternativly you could just send to the server moving in this direction and then client mirrors when you stop moving u say to the server "I've stoped moving"a dn then the sever will let all the other player's know u've stopped

^^The above will only contact ther server whena change has been made..not on a enter frame or Interval