Questions on updating my node.js game

I am making a small game using node.js for the server and the .js file embedded in the HTML5 canvas for clients. Each player also has an object with which they can be moved using the arrow keys.

Now I made two different ways to update the game, each time sending a new player position every time he changed. It worked, but my server had to process about 60 x / y pairs per second (the update speed for the client was 30 / sec, and there were 2 players who moved non-stop). The second method was to send a new position and speed / direction of the player’s object when they change the speed of their direction, so basically on other clients the player’s movement was interpolated using the direction / speed from the last update. My server had to handle very few x / y7speed / direction packets, however, my clients experienced a slight lag when packets arrived since the interpolated position was often slightly different from the actual position recorded in the packet.

Now my questions are: which method would you recommend? And how do I make backlog compensation for any method?

+7
source share
1 answer

If your latency is low, interpolate from the position where the object will make up the new position. With low latency, this does not make much difference.

If you have high latency, you can implement some kind of EPIC. http://www.mindcontrol.org/~hplus/epic/

You can also check how this is done in Browser-Quest. https://github.com/mozilla/BrowserQuest

Good luck

+3
source

All Articles