Depending on how advanced you want to make it you could let the server be in charge still let the client do some work like this:
This is the Unreal Model in short:
Client Send --> Server
Client continues to update physics..
Server get msg from Client.
Server checks the time the packet took to arrive. (Your Ping). The message contained position and acceleration. The server predicts where the client should be.
Server Send --> Client with this prediction.
Server sends this prediction to all other players too.
Client receives MSG and checks the time the packet took to arrive. The Client then steps back in time (you need to save some previous data) to where the prediction was. The client now sets the location of this server packet and now steps forward in time with the latency of the message. In this way all clients see the other clients closer to their true positions
A more simple approach would be to send player input (which keys he is holding down) and updating the physics at all clients. To make sure you don't get out-of-sync you need to (once in a while) send Full updates with X,Y,Dir. A good way is also to send more updates when a collision occur. Also when you apply updates you should consider the delay the packet took.
To get the time for a packet I would recommend you to Sync-clocks
This is the Unreal Model in short:
Client Send --> Server
Client continues to update physics..
Server get msg from Client.
Server checks the time the packet took to arrive. (Your Ping). The message contained position and acceleration. The server predicts where the client should be.
Server Send --> Client with this prediction.
Server sends this prediction to all other players too.
Client receives MSG and checks the time the packet took to arrive. The Client then steps back in time (you need to save some previous data) to where the prediction was. The client now sets the location of this server packet and now steps forward in time with the latency of the message. In this way all clients see the other clients closer to their true positions
A more simple approach would be to send player input (which keys he is holding down) and updating the physics at all clients. To make sure you don't get out-of-sync you need to (once in a while) send Full updates with X,Y,Dir. A good way is also to send more updates when a collision occur. Also when you apply updates you should consider the delay the packet took.
To get the time for a packet I would recommend you to Sync-clocks