When I started this project, I really did not realize how complex the multiplayer coding would be. But it is very interesting and I really wanted to create something I could play online with my friends.
At the time of this blog post, Space Frigates is able to be played multiplayer but the performance is very bad once you have more than one or two players. So I’ve been looking for help and found a couple of great resources that I think will help me and maybe help you too.
Gaffer on Games – A web site with lots of posts from Glenn Fiedler about game development. He covers a lot of ground with respect to physics simulations and how networking challenges can be tackled. Very good resource!
Client-Server Game Architecture – A series from Gabriel Gambetta that contain some very detailed information and concluding a live demo app the demonstrates the different techniques in motion. You can even turn techniques on and off to see how the simulation performs with and without them. Very helpful!!!
Real Time Multiplayer in HTML5 – An article that covers this subject using a demo app written using NodeJS, Socket.io and Canvas / HTML5. Sven Berstrom goes through the demo and explains how everything works.
At this point, I have implemented the “client prediction” technique. This is where you run the game engine locally in the browser so that your commands are carried immediately. Then we you get the current state from the server you overwrite your local state.
But I have not yet implemented “server reconciliation”. This technique addressed the issue where the current state coming back from the server is older than your current local state. So, visually, you see you ship jittering badly as it move forward only to get pulled back again. Over and Over. I don’t totally under stand it yet but the articles above have lots of guidance on the subject. I’m hoping to this working and then blog about it.