Ask coding questions

← Back to all posts
Multiplayer game not rendering other players at the right position
MisterToenails

I am making a multiplayer game with socket.io, node.js, express, and js on the HTML5 canvas. I am having trouble with rendering the other players correctly, as the map is bigger than the screen, so I trim the map image with the correct paramaters based on the players X and Y, and render the player at the center of the screen to create the illusion of movement. When you move, you see the other players move with you, as opposed to staying in a fixed position and having your viewport move away from them. To see the problem, open up two tabs, hit play on both of them and move one around. The repl here is a recreation of the problem, so no harm done if your solution doesn't work, and I would be glad to give you edit access to try some things out. Thanks!

Voters
MisterToenails