Another week has passed and its time for a blog post! As planned this has been a week of networking with a lot of frustrations. But more on that towards the end. First a little roundup of what I have been doing.
Monday was milestone 2 so that entire day was spent preparing and doing that presentation. Tuesday and Wednesday was spent getting socket.io working, read more about this in the post Networking where I explain some implementation details. And lastly Thursday and Friday has been devoted to making the player movement work.
So have I encountered any problems? Short answer: YES. First off I required more time than planned on porting the client code to work on the server. But the biggest problem came forth when trying to make the player paddle move smoothly while maintaining server authority and not clogging up the network by sending the position each frame. After a lot of testing the solution I went with was a similar solution that is explained in Fast Paced Multiplayer by Gabriel Gambetta. I allocate an array with some 10 vectors when the player is created This buffer is then used to store the position each frame. When a message is received with a new position (about every 100-150 ms) the buffer is checked to determine if the position sent from the server is one that the player has visited in which case no correction is required. Otherwise the position is corrected and in both cases the pointer to the buffer is reset to 0. This works quite well but might need some modification since the last position calculated and received before the paddle stops are not exactly the same due to network latency when sending the keyup message.
For now the other connected players have no inter/extrapolation so they only move when the server sends the new position. Fixing this is what I’m planning on doing next week. And per tradition here are some screenshots.
Its difficult to illustrate multiplayer in just images but an indication visible in the above images is that they don’t see the same planet in the background since they are on opposite sides of the playing field.
I plan on updating the stable site this weekend but first I have to install node and all the plugins used.