Это мой текущий код: (все варианты коммутаторов похожи)
void mousePressed() {
if(firstClick == true){//first time to start game
if (mousePressed == true){
if(mouseX >= width/2.0 - (3.0*width/8.0) && mouseX <= width/2.0 + (3.0*width/8.0) && mouseY >= height/2.0 - height/8.0 && mouseY <=height/2.0 + height/8.0){//start button pressed
drawBall();
firstClick = false;
}
}
}
else{
drawBall();//clear screen
if(mousePressed == true){
if(mouseX <= width - width/20.0 && mouseX >= width - 3.0*width/20.0 && mouseY <= height - height/30.0 && mouseY >= height - 5.0*width/30.0){//play button pressed
int fortune = (int)random(0,8);
switch(fortune)//fortunes
{
case 0:
textSize(25*height/800);
fill(255);
text("Fortunes are for people who cant understand RND.",width/2, height/2);
case 1:
textSize(25*height/800);
fill(255);
text("You will be overrun by sadness :(",width/2, height/2);
case 2:
textSize(25*height/800);
fill(255);
text("You will have great luck today 1",width/2, height/2);
case 3:
textSize(25*height/800);
fill(255);
text("You will fail a test :(",width/2, height/2);
case 4:
textSize(25*height/800);
fill(255);
text("You will get a good score on a test!",width/2, height/2);
case 5:
textSize(25*height/800);
fill(255);
text("No one will listen to you today :(",width/2, height/2);
case 6:
textSize(25*height/800);
fill(255);
text("You will get what you want!",width/2, height/2);
case 7:
textSize(25*height/800);
fill(255);
text("Your day will suck :(",width/2, height/2);
default:
textSize(25*height/800);
fill(255);
text("You will have a great day!",width/2, height/2);
}
}
}
}
Когда я запускаю код.Это слой текста, хотя я ввел функцию DrawBall (которая очищает доску).Это заставляет меня верить, что это что-то с переключателем.Я хочу, чтобы код выдавал единицу на выходе при каждом нажатии мыши.Что мне делать?