xxxxxxxxxx
114
let questions = [
"The sky is blue.",
"Because of the way Earth's atmosphere scatters sunlight.",
"Due to the composition of gases and particles present in the atmosphere.",
"Because of natural processes and human activities.",
"Because they interact with the environment and produce certain byproducts.",
"Because that's just how things work in our complex world.",
"Because it's a product of countless interactions and variables.",
"Because the universe is vast and diverse, leading to infinite possibilities.",
"Because... well, it just is. It's a cosmic mystery.",
"Because... umm... it's beyond human comprehension.",
"Do you really think I have all the answers? Why don't you figure it out?",
"life is full of uncertainties, sometimes there is no answer!",
"Why do you keep asking why? maybe you should ask yourself why?",
"OK this is getting childish...",
"Are you gonna stop? this is getting annoying",
"...I refuse to entertain this line of questioning any further.",
"..."
];
let currentQuestionIndex = 0;
let option1 = "Why?";
let option2 = "Why?";
let backgroundColor;
let textColor;
let shakeAmount;
function setup() {
createCanvas(1000, 400);
textAlign(CENTER);
textSize(24);
textFont("Courier New");
backgroundColor = color(120,120,255);
textColor = color(255);
textStyle(BOLD);
shakeAmount = 0;
}
function draw() {
background(backgroundColor);
// Display the question
applyShake();
fill(textColor);
// text(questions[currentQuestionIndex], width / 2, height / 2 - 100);
// Display option 1
textSize(20);
applyShake();
text("A) " + option1, width / 2 - 120, height / 2 + 10);
// Display option 2
applyShake();
text("B) " + option2, width / 2 + 120, height / 2 + 10);
}
function applyShake() {
let numLetters = textWidth(questions[currentQuestionIndex]) / questions[currentQuestionIndex].length;
for (let i = 0; i < questions[currentQuestionIndex].length; i++) {
let shakeOffsetX = random(-shakeAmount, shakeAmount);
let shakeOffsetY = random(-shakeAmount, shakeAmount);
text(
questions[currentQuestionIndex].charAt(i),
width / 2 - textWidth(questions[currentQuestionIndex]) / 2 + numLetters * i + shakeOffsetX,
height / 2 - 100 + shakeOffsetY
);
}
}
function mouseClicked() {
// Check if option 1 is clicked
if (
mouseX > width / 2 - 170 &&
mouseX < width / 2 - 70 &&
mouseY > height / 2 - 20 &&
mouseY < height / 2 + 20
) {
console.log("Option 1 selected");
shakeAmount += 0.3;
changeColors();
nextQuestion();
// Add your code here for the action to be taken when option 1 is selected
}
// Check if option 2 is clicked
if (
mouseX > width / 2 + 70 &&
mouseX < width / 2 + 170 &&
mouseY > height / 2 - 20 &&
mouseY < height / 2 + 20
) {
console.log("Option 2 selected");
shakeAmount += 0.3;
changeColors();
nextQuestion();
// Add your code here for the action to be taken when option 2 is selected
}
}
function changeColors() {
backgroundColor = color(random(256), random(256), random(256));
textColor = color(
255 - red(backgroundColor),
255 - green(backgroundColor),
255 - blue(backgroundColor)
);
}
function nextQuestion() {
currentQuestionIndex++;
if (currentQuestionIndex >= questions.length) {
currentQuestionIndex = questions.length - 1; // Repeat the last question
}
}