Hi, @Lexyth
My app is finished but I need to change hand clock speed from 1 second to 2 seconds. I have changed every second() in my code to (second()*2), but the clock breaks. How could I make that the hand clock moves every 2 second, but without jumping any of the 10 points? Please remember the hand clock has to start always at 12 o clock.
Thank you!!!
int cx, cy;
float offset;
float secondsRadius;
float clockDiameter;
void setup(){
size(270,540);
background(0,0,0);
noStroke();
offset = (second()*2);
int radius = min(width, height) / 2;
secondsRadius = radius * 0.72;
clockDiameter = radius * 1.8;
cx = width / 2;
cy = height / 2;
}
//first scene lasts 5 seconds
void scene1() {
background(0,0,0);
fill(255, 255, 255, 255);
textSize(height/12);
textAlign(RIGHT, CENTER);
text("deep", width/2, height/2);
fill(255, 204 , 0, 255);
textSize(height/12);
textAlign(LEFT, CENTER);
text("focus", width/2, height/2);
fill(255, 95, 95, 255);
textSize(height/36);
textAlign(CENTER, CENTER);
text("@deepfocusapp", width/2, height/1.1);
}
//second scene has a button that activates third scene
void scene2() {
String a = "1. Cuenta del 100 al 1 siguiendo la aguja del reloj. Cuando llegues al 1, vuelve a empezar.";
String b = "2. Cada vez que te distraigas, devuelve tu atención a la manecilla y continúa con la cuenta descendente.";
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/2.85);
textSize(height/34);
text(b, width/10, height/2.22, width/1.2, height/2);
//this is my button
stroke(255,95,95);
strokeWeight(55);
point(width/2, height/1.3);
stroke(255);
strokeWeight(30);
point(width/2, height/1.3);
stroke(255,95,95);
strokeWeight(25);
point(width/2, height/1.3);
stroke(255);
strokeWeight(5);
point(width/2, height/1.3);
}
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()*2)-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";
boolean pressIsNew = false;
void draw () {
switch (scene) {
case "initial":
if (millis() > 5000) scene = "millis5000";
scene1();
break;
case "millis5000":
scene2();
if (pressIsNew && mousePressed && dist(mouseX, mouseY, width/2, height/1.3) < height/9) {
offset = second();
pressIsNew = false;
scene = "scene3";
}
if (!mousePressed) pressIsNew = true;
break;
case "scene3" :
if (mousePressed && pressIsNew) {
scene = "millis5000";
pressIsNew = false;
}
if (!mousePressed) pressIsNew = true;
scene3();
break;
default:
scene1();
break;
}
}