I’m brand new to processing, completely new. ‘I’m 15 and learning it in class’ type new. My teacher doesnt know a thing about what im doing, but I want to finish this if possible.
I’m trying to make a quiz, essentially. I have to have 5 questions, and each question has to have at least 3 possible answers.
I have so many issues with this code. I can’t get the third question to even come up, I can’t make the answers to the questions different(currently the answers are all B) and so many more issues.
Here’s the code.
Thanks to anyone who tries to help, and im sorry in advance because im confident this is awful.
void setup() {
size(700, 700);
background(255);
PFont font1;
font1 = createFont("ACaslonPro-Regular-48", 23);
}
//disclaimer!! bugs!! the yes and no will still work after with other questions.
//you have to right click the window so DO NOT USE RIGHT FOR A CHANGE!!!
//for some reason clicking left twice clears the yes/no.
//dunno if i can have more than 3 things! maybe instead of binding to click bind to a new key.
boolean callMethod = true;
void draw() {
fill(255);
stroke(255);
rect(1, 1, 50, 700);
int correctanswers = 0;
surface.setTitle(mouseX + ", " + mouseY);
stroke(0);
fill(0);
textSize(23);
if (callMethod){
text("What is the capital of Alberta?", 56, 58);
text("Press a if you think it's Red Deer.", 56, 104);
text("Press b if you think it's Edmonton.", 56, 152);
text("Press c if you think it's Sherwood Park.", 56, 200);
callMethod = false;
}
if (keyPressed) {
if (key == 'a'){
wrongAnswer();
} else if (key == 'b') {
correctAnswer();
} else if (key == 'c') {
wrongAnswer();
} else {
wrongInput();
}
}
//answer end
if (mousePressed && mouseButton == LEFT){
question2();
text("Press a if you think it's K.", 57, 95);
text("Press b if you think it's Na.", 57, 127);
text("Press c if you think it's S.", 57, 160);
}
if (mousePressed && mouseButton == RIGHT) {
question3();
}
}
//personal functions
void question3() {
if (mousePressed && mouseButton == LEFT) {
fill(255);
rect(1, 1, 700, 700);
fill(0);
text("Who teaches science 10?", 56, 58);
}
}
void question2() {
if (mousePressed && mouseButton == LEFT) {
fill(255);
rect(1, 1, 700, 700);
fill(0);
text("What is the symbol for sodium on the periodic table?", 56, 58);
}
}
void wrongAnswer() {
fill(255);
stroke(255);
rect(52, 229, 300, 100);
fill(0);
stroke(0);
text("Wrong! Click to continue.", 59, 250);
}
void wrongInput() {
fill(255);
stroke(255);
rect(52, 229, 300, 100);
fill(0);
stroke(0);
text("Follow the rules!", 59, 250);
}
void correctAnswer () {
int correctanswers = 0;
fill(255);
stroke(255);
rect(52, 229, 300, 100);
fill(0);
stroke(0);
text("Correct! Click to continue.", 59, 250);
correctanswers = correctanswers + 1;
}