Code
Code
(answerRectX = 100),
(answerRectY = 50),
(questionX = -1),
(questionY = 10),
];
let questions = [
{
}
];
let answers = [
{
}
];
function setup() {
createCanvas(800, 600);
background(157, 0, 255);
startButton = createButton("Start Quiz");
startButton.position(280, 220);
startButton.size(220, 140);
startButton.style("border-radius", "10px");
startButton.style("font-size", "35px");
startButton.style("font-family", "Impact");
startButton.style("color", "black");
startButton.mousePressed(vraag1);
}
function draw() {}
//vraag 1
function vraag1() {
isInVragen1 = true;
startButton.remove();
background(157, 0, 255);
strokeWeight(2);
fill("white");
rect(startScherm[2], startScherm[3], 810, 75);
fill("black");
textSize(24);
text(
"Vraag 1: Wat is de waarde van π (pi) tot op twee decimalen nauwkeurig?",
10,
55
);
for (let i = 0; i < 2; i++) {
fill("white");
rect(answerXpos + 448 * i, answerYpos, 300, 75);
rect(answerXpos + 448 * i, answerYpos + 125, 300, 75);
}
fill("black");
text("3,11", answerXpos + 130, 420);
text("3,12", answerXpos + 130, 545);
text("3,13", answerXpos + 580, 420);
text("3,14", answerXpos + 580, 545);
}
function mousePressed() {
if (isInVragen1) {
if (
mouseX > answerXpos &&
mouseX < answerXpos + 300 &&
mouseY > answerYpos &&
mouseY < answerYpos + 75
) {
createCanvas(800, 600);
background("red");
fill("black");
textSize(24);
textFont("Impact");
text("WRONG ANSWER!!!", 310, 300);
}
if (
mouseX > answerXpos + 448 &&
mouseX < answerXpos + 448 + 300 &&
mouseY > answerYpos &&
mouseY < answerYpos + 75
) {
createCanvas(800, 600);
background("red");
fill("black");
textSize(24);
textFont("Impact");
text("WRONG ANSWER!!!", 310, 300);
}
if (
mouseX > answerXpos &&
mouseX < answerXpos + 300 &&
mouseY > answerYpos + 125 &&
mouseY < answerYpos + 200
) {
createCanvas(800, 600);
background("red");
fill("black");
textSize(24);
textFont("Impact");
text("WRONG ANSWER!!!", 310, 300);
}
if (
mouseX > answerXpos + 448 &&
mouseX < answerXpos + 448 + 300 &&
mouseY > answerYpos + 125 &&
mouseY < answerYpos + 200
) {
createCanvas(800, 600);
background(0, 255, 68);
fill("black");
textSize(24);
textFont("Impact");
text("CORRECT ANSWER!!", 310, 300);
}
}
}
//vraag 1