setup()
setup() runs once when the sketch starts. Here we initialize the canvas size, record the starting time, and configure text settings. Using windowWidth and windowHeight makes the sketch adapt to any screen size.
function setup() {
createCanvas(windowWidth, windowHeight);
startTime = millis();
textAlign(CENTER, TOP);
textSize(24);
}
Line by Line:
createCanvas(windowWidth, windowHeight)- Creates a canvas that fills the entire browser window, making the sketch responsive to different screen sizes
startTime = millis()- Records the current time in milliseconds when the sketch starts, used later to calculate how much time has passed
textAlign(CENTER, TOP)- Sets text alignment so that text is centered horizontally and aligned to the top vertically
textSize(24)- Sets the font size to 24 pixels for the stage labels