I am developing a 2D side-scrolling multiplayer game using Node.js. I'm having issues debugging certain aspects of the development process (ex: collision detection, player movement, latency, etc.).
It is my understanding
console.log is a synchronous operation that will block the game loop until it is complete. If I perform a
console.log multiple times per frame, the game server will slow down tremendously.
Currently, I am trying to debug if any given player will collide with a collidable block. My debugging method works as follows:
- Calculate next predicted position for a player, call it
nextPos.y, check the world map if a collision will occur.
- Print the result from
worldMap[x][y]to see what value is received (expected output is an integer).
However, since I
console.log at least once per frame, the server cannot send messages to the client, and therefore the game freezes on client.
What are some ways I can debug information on the server without ruining client gameplay? I understand when the game is in production, there will be no need for debugging.