preload()
preload() is a p5.js lifecycle function that runs before setup(). For text adventures, it's empty because we don't load external media files, but including it follows p5.js conventions.
function preload() {
console.log("--- preload() called ---");
// Not used for this text-based game, but required by p5.js structure
}
Line-by-line explanation (2 lines)
function preload() {- Declares the preload function, which p5.js calls before setup(); used for loading images and sounds, but not needed here
console.log("--- preload() called ---");- Logs a message to the browser console to indicate preload was called, helping trace code execution