I think to create a class or an objetct its too complicated for me, but even forgetting that and using this other opcion, the code is not working:
if ((mousePressed) && (mouseX > width/2-50 && mouseX < width/2+50 && mouseY < height/1.35 + 50 && mouseY > height/1.35 -50)){
}
Error says “unreachable code”
This is complete code
int cx, cy;
int offset;
float secondsRadius;
float clockDiameter;
void setup(){
size(270,540);
background(0,0,0);
noStroke();
offset = second();
int radius = min(width, height) / 2;
secondsRadius = radius * 0.72;
clockDiameter = radius * 1.8;
cx = width / 2;
cy = height / 2;
}
void scene1() {
background(0,0,0);
fill(255, 255, 255, 255);
textSize(height/12);
textAlign(RIGHT, CENTER);
text("blabla", width/2, height/2);
fill(255, 204 , 0, 255);
textSize(height/12);
textAlign(LEFT, CENTER);
text("blabla", width/2, height/2);
fill(255, 95, 95, 255);
textSize(height/36);
textAlign(CENTER, CENTER);
text("blablabla", width/2, height/1.1);
}
void scene2() {
String a = "1. Cuenta cada círculo que aparece en la pantalla.";
String b = "2. Cada vez que te distraigas, devuelve tu atención a los círculos que estás contando.";
String c = "Instrucciones.";
background(255);
fill(0);
stroke(255,95,95);
strokeWeight(1);
line(width/10, height/5, width/1.15, height/5);
textAlign(LEFT, TOP);
textSize(height/22);
text(c, width/10, height/10, width/1.2, height/6.66);
textSize(height/34);
text(a, width/10, height/4, width/1.2, height/3.33);
textSize(height/34);
text(b, width/10, height/2.5, width/1.2, height/2.22);
//this is my button
fill(255,95,95);
noStroke();
circle(width/2, height/1.35, height/9);
noFill();
stroke(255);
strokeWeight(4);
circle(width/2, height/1.35, height/16);
noStroke();
fill(255);
circle(width/2, height/1.35, height/80);
}
void scene3(){
background(247,108,127);
float l = width/255;
strokeWeight(1);
for(int i = 0; i<width; i++) {
stroke(252,150,120,255-i/(l));
line(i,0,i, height);
}
float s = -map(second()-offset, 0, 10, 0, TWO_PI) -HALF_PI;
stroke(255);
strokeWeight(5);
line(cx, cy, cx + cos(s) * secondsRadius, cy + sin(s) * secondsRadius);
strokeWeight(5);
beginShape(POINTS);
for (int a = 0; a < 360; a+=36) {
float angle = radians(a)+HALF_PI;
float x = cx + cos(angle) * secondsRadius;
float y = cy + sin(angle) * secondsRadius;
vertex(x, y);
}
endShape();
}
String scene = "initial";
void draw () {
switch (scene) {
case "initial":
if (millis() > 5000) scene = "millis5000";
scene1();
break;
case "millis5000":
scene2();
break;
default:
scene1();
break;
if ((mousePressed) && (mouseX > width/2-50 && mouseX < width/2+50 && mouseY < height/1.35 + 50 && mouseY > height/1.35 -50)){
scene3();
}
}
}