🔬 The cursor blinks because 'frameCount % 30' cycles from 0–29 each 30 frames. The condition '< 15' makes it visible for frames 0–14, invisible for 15–29. What happens if you change '< 15' to '< 20'? Will the cursor blink faster, slower, or spend more time visible?
// Blinking cursor if this input is active
if (selectedInput === option.gameStateVar && frameCount % 30 < 15) {
stroke(0, 255, 0);
strokeWeight(2);
line(inputX + 5 + textWidth(option.value), inputY + 5, inputX + 5 + textWidth(option.value), inputY + inputHeight - 5);
// Helper function to draw an input field
drawInput: function(label, bx, by, bw, bh, option) {
push();
fill(30, 80, 30); // Dark green background for input area
stroke(0, 150, 0);
strokeWeight(2);
rectMode(CORNER);
rect(bx, by, bw, bh, 5);
// Label
fill(0, 255, 0);
textAlign(LEFT, CENTER);
textSize(16);
textFont(modMenuFont);
text(label, bx + modMenu.padding, by + bh / 4);
// Input box
const inputX = bx + modMenu.padding;
const inputY = by + bh / 2 + 5;
const inputWidth = bw - modMenu.padding * 2;
const inputHeight = bh / 2 - 10;
fill(0, 0, 0, 180); // Darker background for the actual input text
stroke(0, 255, 0); // Bright green border
strokeWeight(1);
rect(inputX, inputY, inputWidth, inputHeight, 3);
// Input text
fill(0, 255, 0);
textAlign(LEFT, CENTER);
textSize(18);
// Draw placeholder if value is empty and not active
if (option.value === "" && selectedInput !== option.gameStateVar) {
fill(0, 150, 0); // Muted green for placeholder
text(option.placeholder, inputX + 5, inputY + inputHeight / 2);
} else {
fill(0, 255, 0); // Bright green for active text
text(option.value, inputX + 5, inputY + inputHeight / 2);
// Blinking cursor if this input is active
if (selectedInput === option.gameStateVar && frameCount % 30 < 15) {
stroke(0, 255, 0);
strokeWeight(2);
line(inputX + 5 + textWidth(option.value), inputY + 5, inputX + 5 + textWidth(option.value), inputY + inputHeight - 5);
}
}
pop();
},