Hello i made some quiz and i can only change 2 page if anyone can show me how can ı reset the page

int page=0;
void setup(){
size(800,600);
page+=1;

}
void draw(){
switch(page){
case 1:drawPage1();break;
case 2:drawPage2();break;
case 3:drawPage3();break;
case 4:drawPage4(); break;
default:break;
}

}

void drawPage1(){
background(0);textSize(15);
fill(255);
text("Jenneferin babasının 3 kızı vardır KızlarınınA adı Lili ve Lulu’dur 3. ismi nedir ",0,100);

if(mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true){
fill(42,255,15);
rect(150,400,100,50);
fill(255,0,0 );
rect(300,400,100,50);
setup();
drawPage2();

}
else if(mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true){

fill(255,0,0 );

rect(300,400,100,50);
fill(42,255,15);
rect(150,400,100,50);
setup();
drawPage2();

}

else {
fill(324,0,115);
rect(150,400,100,50);
fill(42,125,1512);
rect(300,400,100,50);
fill(255);
text(“Jennifer”,185,430);
text(“Lala”,340,430);

}

}
void drawPage2(){

background(0); textSize(15);
fill(255);
text(“5 Katlı binanın son katına çıkmak için kaç merdiven çıkmak gerekir”,0,100);

if(mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true){
fill(42,255,15);
rect(150,400,100,50);
fill(255,0,0 );
rect(300,400,100,50);
setup();
drawPage3();

}
else if(mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true){

fill(255,0,0 );

rect(300,400,100,50);
fill(42,255,15);
rect(150,400,100,50);
setup();
drawPage3();

}

else {
fill(324,0,115);
rect(150,400,100,50);
fill(42,125,1512);
rect(300,400,100,50);
fill(255);
text(“6”,185,430);
text(“5”,340,430);

}

}
void drawPage3(){
textSize(15);
fill(255);
text(“ANAN”,0,100);

if(mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true){
fill(42,255,15);
rect(150,400,100,50);
fill(255,0,0 );
rect(300,400,100,50);

}
else if(mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true){

fill(255,0,0 );

rect(300,400,100,50);
fill(42,255,15);
rect(150,400,100,50);

}

else {
fill(324,0,115);
rect(150,400,100,50);
fill(42,125,1512);
rect(300,400,100,50);
fill(255);
text(“62”,185,430);
text(“123”,340,430);

}

}

void reset(){

setup();

}
void drawPage4(){
textSize(15);
fill(255);
text(“ANAN AND BACIN”,0,100);

if(mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true){
fill(42,255,15);
rect(150,400,100,50);
fill(255,0,0 );
rect(300,400,100,50);

}
else if(mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true){

fill(255,0,0 );

rect(300,400,100,50);
fill(42,255,15);
rect(150,400,100,50);

}

else {
fill(324,0,115);
rect(150,400,100,50);
fill(42,125,1512);
rect(300,400,100,50);
fill(255);
text(“62”,185,430);
text(“123”,340,430);

}
}

Please use code tags

You should not call setup() when the right answer is provided, you should just increment your page index and the switch will draw the next quizz. If at the end of quizz 4 you want to go back to the first quizz, just set the page number to 1

When I try to switch from drawPage2 to drawPage3 drawPage2 does not disappear from the screen can you show me the true please I’ve been trying to do this for 2 days

At start of draw() always say background…

it definitely changed something thank you , but after printing 2 pages every time, I can’t switch to 3 please can someone do it and show it please

here is my code! I did it for fun, so you probably won’t learn too much from it. I blured it so you don’t have to see it!

ArrayList<String[]> questions = new ArrayList<String[]>();
ArrayList<Integer> cAnswer = new ArrayList<Integer>();
int cq = 0, bSize = 40;
String ans[] = {"a","b","c","d","e","f","g"};

void setup() {
  size(600,600);
  String q[] = {"What is 1 + 2 ?","a) two ","b) three ", "c) four ", "d) five"};
  questions.add(q);
  cAnswer.add(3); //third item on q[] list 
  
  String q2[] = {"What is 2 * 3 ?","a) four ","b) five ", "c) six ", "d) seven", "e) eight"};
  questions.add(q2);
  cAnswer.add(4);
  
  String q3[] = {"What is this program's creator Processing-forum name?", "a) Nick ", "b) Paul ", "c) CodePro69 ", "d) CodeMasterX", "e) Jeff Jefferson"};
  questions.add(q3);
  cAnswer.add(5);
  
  String q4[] = {"This will be the end no buttons will work anymore", "a) why? ", "b) cuz I'm lazy", "c) farewell"};
  addQuestion(q4,-1);
  
  textAlign(3,3);
}

void draw() {
  background(0);
  fill(255);
  String cQ[] = questions.get(cq);
  text(cQ[0],width/2,50);
  for(int i = 0; i < cQ.length-1; i ++) {
    text(cQ[i+1],width/2,100+i*30);
  }
  for(int i = 0; i < cQ.length; i++) {
    noFill();
    stroke(255);
    circle(map(i,0,cQ.length-2,width/8,width/8*7),height/2,bSize);
    fill(255);
    text(ans[i],(map(i,0,cQ.length-2,width/8,width/8*7)),height/2);
  }
}

void mousePressed() {
  for(int i = 0; i < questions.get(cq).length;i++) {
    if(dist(mouseX,mouseY,(map(i,0,questions.get(cq).length-2,width/8,width/8*7)),height/2) < bSize) {
      if(i == cAnswer.get(cq)-2) {
        println("Correct!");
        cq++;
      } else {
        println("Incorrect");
      }
    }
  }
}

void addQuestion(String[] text, int correctAnswer) {
  questions.add(text);
  cAnswer.add(correctAnswer);
}

I’m definitely trying to do something like this but I don’t have enough information to do this. Can you browse mine? Why can’t I go to 3 pages?

the issue is with the drawPage3 it is due to skipping the 2nd since the answers are the same. Your system is flawed due to not using the

void mousePressed() {
   if(inBox) do something;
}

and the reason why you can’t see the 4th page is because you forgot to call the setup() in the 3rd page.

I modified it so it works a bit better. I still can’t sort it out because the code is a bit messy : P

int page=0;
boolean pressed = false;
void setup() {
  size(800, 600);
  page+=1;
  pressed = true;
}
void draw() {
  background(0);
  switch(page) {
  case 1:
    drawPage1();
    break;
  case 2:
    drawPage2();
    break;
  case 3:
    drawPage3();
    break;
  case 4:
    drawPage4(); 
    break;
  default:
    break;
  }
}

void drawPage1() {
  background(0);
  textSize(15);
  fill(255);
  text("Jenneferin babasının 3 kızı vardır KızlarınınA adı Lili ve Lulu’dur 3. ismi nedir ", 0, 100);

  if (mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true && !pressed) {
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    setup();
    //drawPage2();
  } else if (mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true&& !pressed) {

    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    setup();
    //drawPage2();
  } else {
    fill(324, 0, 115);
    rect(150, 400, 100, 50);
    fill(42, 125, 1512);
    rect(300, 400, 100, 50);
    fill(255);
    text("Jennifer", 185, 430);
    text("Lala", 340, 430);
  }
}
void drawPage2() {

  background(0); 
  textSize(15);
  fill(255);
  text("5 Katlı binanın son katına çıkmak için kaç merdiven çıkmak gerekir", 0, 100);

  if (mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true&& !pressed) {
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    setup();
    //drawPage3();
  } else if (mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true&& !pressed) {

    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    setup();
    //drawPage3();
  } else {
    fill(324, 0, 115);
    rect(150, 400, 100, 50);
    fill(42, 125, 1512);
    rect(300, 400, 100, 50);
    fill(255);
    text("6", 185, 430);
    text("5", 340, 430);
  }
}
void drawPage3() {
  textSize(15);
  fill(255);
  text("ANAN", 0, 100);

  if (mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true&& !pressed) {
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    setup();
  } else if (mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true&& !pressed) {

    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    setup();
  } else {
    fill(324, 0, 115);
    rect(150, 400, 100, 50);
    fill(42, 125, 1512);
    rect(300, 400, 100, 50);
    fill(255);
    text("62", 185, 430);
    text("123", 340, 430);
    setup();
  }
}

void reset() {

  setup();
}
void drawPage4() {
  textSize(15);
  fill(255);
  text("ANAN AND BACIN", 0, 100);

  if (mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true&& !pressed) {
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
  } else if (mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true&& !pressed) {

    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
  } else {
    fill(324, 0, 115);
    rect(150, 400, 100, 50);
    fill(42, 125, 1512);
    rect(300, 400, 100, 50);
    fill(255);
    text("62", 185, 430);
    text("123", 340, 430);
  }
}

void mouseReleased() {
  pressed = false;
}

1 Like

fixed it all. I don’t know the language so the answers might be weird

int page=0;
boolean pressed = false;
void setup() {
  size(800, 600);
  page+=1;
  pressed = true;
}
void draw() {
  background(0);
  switch(page) {
  case 1:
    drawPage1();
    break;
  case 2:
    drawPage2();
    break;
  case 3:
    drawPage3();
    break;
  case 4:
    drawPage4(); 
    break;
  }
}

void drawPage1() {
  background(0);
  textSize(15);
  fill(255);
  text("Jenneferin babasının 3 kızı vardır KızlarınınA adı Lili ve Lulu’dur 3. ismi nedir ", 0, 100);

  if (mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true && !pressed) {
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    setup();
    //drawPage2();
  } else if (mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true&& !pressed) {

    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    setup();
    //drawPage2();
  } else {
    fill(324, 0, 115);
    rect(150, 400, 100, 50);
    fill(42, 125, 1512);
    rect(300, 400, 100, 50);
    fill(255);
    text("Jennifer", 185, 430);
    text("Lala", 340, 430);
  }
}
void drawPage2() {

  background(0); 
  textSize(15);
  fill(255);
  text("5 Katlı binanın son katına çıkmak için kaç merdiven çıkmak gerekir", 0, 100);

  if (mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true&& !pressed) {
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    setup();
    //drawPage3();
  } else if (mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true&& !pressed) {

    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    setup();
    //drawPage3();
  } else {
    fill(324, 0, 115);
    rect(150, 400, 100, 50);
    fill(42, 125, 1512);
    rect(300, 400, 100, 50);
    fill(255);
    text("6", 185, 430);
    text("5", 340, 430);
  }
}
void drawPage3() {
  background(0); 
  textSize(15);
  fill(255);
  text("ANAN", 0, 100);

  if (mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true&& !pressed) {
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    setup();
    //drawPage3();
  } else if (mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true&& !pressed) {

    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    setup();
    //drawPage3();
  } else {
    fill(324, 0, 115);
    rect(150, 400, 100, 50);
    fill(42, 125, 1512);
    rect(300, 400, 100, 50);
    fill(255);
    text("62", 185, 430);
    text("123", 340, 430);
  }
}

void reset() {

  setup();
}

void drawPage4() {
  textSize(15);
  fill(255);
  text("ANAN AND BACIN", 0, 100);

  if (mouseX>150 && mouseY>400 && mouseX<250 && mouseY<450 && mousePressed==true&& !pressed) {
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
  } else if (mouseX>300 && mouseY>400 && mouseX<400 && mouseY<450 && mousePressed==true&& !pressed) {

    fill(255, 0, 0 );
    rect(300, 400, 100, 50);
    fill(42, 255, 15);
    rect(150, 400, 100, 50);
  } else {
    fill(324, 0, 115);
    rect(150, 400, 100, 50);
    fill(42, 125, 1512);
    rect(300, 400, 100, 50);
    fill(255);
    text("62", 185, 430);
    text("123", 340, 430);
  }
}

void mouseReleased() {
  pressed = false;
}

1 Like

do you use any social media CodeMasterX

nope. I am honestly not interested. I already have too many time-taking hobbies : P I never really understood social media, so I don’t have anything but my youtube account I use for watching yt