setup()
setup() runs once when the sketch starts. It's the perfect place to initialize your canvas, load resources, and set up initial game state.
function setup() {
createCanvas(windowWidth, windowHeight);
setupAudio();
initGame();
}
Line by Line:
createCanvas(windowWidth, windowHeight)- Creates a canvas that fills the entire browser window, making the game responsive to different screen sizes
setupAudio()- Initializes the audio system by creating oscillators for ambient background sound
initGame()- Initializes all game objects (player, enemies, orbs) and resets game variables to start state