Skip to content

🪲 Debugging

  1. Make sure Live Server is running.

  2. In Visual Studio Code, hit F5 or Run -> Start Debugging.

  3. It will ask which configuration to use, select Chrome.

  4. In the launch.json it creates, make sure the port number is the same port number that Live Server is using, usually 5500.

  5. Hit F5 or Run -> Start Debugging again, and a window should open up with the game running. You can now add breakpoints to the code.

  6. Hard code the value of deltaTime.

    Game.js
    gameLoop(currentTime = 0) {
    // Calculates delta time and converts it to seconds instead of milliseconds.
    const deltaTime = (currentTime - this.lastTime) / 1000;
    const deltaTime = 0.016;
    this.update(deltaTime);
    this.lastTime = currentTime;
    requestAnimationFrame((time) => this.gameLoop(time));
    }