I'm building a multiplayer snake-like game with Javascript. I'm having problems with the precision of the opposite players location not reacting fast enough. Which in turns makes the worm "crash", but only for some players, where the change in position happened too late due to latency.
My current game logic sends the change in direction, eg: "Up","Left" as soon as player #1 reacts.
Player #2 then receives Player#1 new direction, and sets his worm to now travel "up" (the direction received).
Since this introduces latency and that the change in direction might be applied too late, i'm wondering what other possibilities is available?
One might be to send current coordinates, or have the game loop on the server aswell, to make sure all movement changes is synced properly.