Debugging with printh

This recipe shows how to use PICO-8's printh() function to output debug information to your terminal.

Setup

Enable pipeOutputToConsole in your config:

// jspicl.config.ts
import type {Config} from "@jspicl/cli/types";

const config: Config = {
pipeOutputToConsole: true,
spritesheetImagePath: "assets/sprites.png",
jsOutput: "build/game.js"
// ...
};

export default config;

Usage

Use printh() anywhere in your game code:

function _update() {
if (btn(0)) {
player.x -= 1;
printh("Player moved left: " + player.x);
}
}

Output

When running in watch mode, you'll see the output in your terminal:

Player moved left: 63
Player moved left: 62
Player moved left: 61

Tips