I tried to make a PONG game which works , and then change it to a multiplayer game.
You can choose the "Game Speed" which is basically how much cycles it takes until the ball can move and send location data.
So every tick (default is 200) the server sends this to
pos:{0}:{1}&ballpos:{2}:{3}&gametick:{4}
(of course its in a String.Format)
and every tick the client sends this to the server :
pos:{0}:{1}
in order to sync the clients location with the hosting player.
it sends the messages with this function :
public static void sendMessage( String message , UdpClient client)
{
Byte[] toSend = new byte[55];
toSend = Encoding.ASCII.GetBytes(message);
client.Send(toSend, toSend.Length);
}
Now when we play , and we are on skype for example , the skype connection quality is really low , and extremely laggy. then the game becomes laggy.
Is there a more efficient way to send data to sync locations?
Here are a few tips:
Updates should be regular, deterministic (you know when they will happen) and non-volatile (missing one isnt a problem). Experiment with slowing the update rate right down and see what happens.