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.).

The Problem:

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:

  1. Calculate next predicted position for a player, call it nextPos.
  2. Using nextPos.x and nextPos.y, check the world map if a collision will occur.
  3. 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.

The Question:

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.

  • 1
    \$\begingroup\$ A single console.log shouldn't freeze the server completely unless the server runs on a dynamic update rate \$\endgroup\$ – Bálint May 14 '19 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.