uprage this one ?
int tmpsstart = 0;
int amili1 = 0;
int mili1 = 0;
int tour1 = 0;
int atour1 = 0;
String chrono1 = "00 : 00 : 00";
int best1=0;
String bests1 = "00 : 00 : 00";
int amili2 = 0;
int mili2 = 0;
int tour2 = 0;
int atour2 = 0;
String chrono2 = "00 : 00 : 00";
int best2=0;
String bests2 = "00 : 00 : 00";
int amili3 = 0;
int mili3 = 0;
int tour3 = 0;
int atour3 = 0;
String chrono3 = "00 : 00 : 00";
int best3=0;
String bests3 = "00 : 00 : 00";
String total = "00 : 00 : 00";
color couleur = color(0, 255, 0); //CHRONO DE 3 VOITURES
void setup() {
size(1360, 768);
background(#000000);
noStroke();
}
void draw() {
background(#94A593);
if (tmpsstart!=0) {
mouse();
total();
fill(#FF0000);
rect(0, height-(height/6), width, height/6); // affichage du rectangle
fill(#000000);
text("STOP", (width/2)-100, height-height/20); // affichage du STOP
fill(#FFFFFF);
text(total, (width/2.5)-10, (height/10)) ; // affichage du chrono general
fill(#94A593);
rect(125, 125, 250, 225, 1);
fill(#94A593);
rect(535, 125, 250, 225, 1);
fill(#94A593);
rect(955, 125, 250, 225, 1);
//voiture 1
fill(#000000);
text("Temp du tour :", 150, 170);
if (atour1>tour1&&atour1!=0) {
fill(#00FF00);
} else {
fill(#FF0000);
}
text(chrono1, 150, 210);
fill(#000000);
text("Meilleur temp :", 150, 250);
fill(#000000);
text(bests1, 150, 290);
//voiture 2
fill(#000000);
text("Temp du tour :", 560, 170);
if (atour2>tour2&&atour2!=0) {
fill(#00FF00);
} else {
fill(#FF0000);
}
text(chrono2, 560, 210);
fill(#000000);
text("Meilleur temp :", 560, 250);
fill(#000000);
text(bests2, 560, 290);
//voiture 3
fill(#000000);
text("Temp du tour :", 980, 170);
if (atour3>tour3&&atour3!=0) {
fill(#00FF00);
} else {
fill(#FF0000);
}
text(chrono3, 980, 210);
fill(#000000);
text("Meilleur temp :", 980, 250);
fill(#000000);
text(bests3, 980, 290);
PImage img; //Variabe des images, cliquez sur les voitures pour affichez le temps
img = loadImage("lotus exige 2k.jpg"); //Image voiture 1
image(img, 100, height-(height/6)*3);
img = loadImage("challenger.jpg"); //Image voiture 2
image(img, 525, height-(height/6)*3);
img = loadImage("911.jpg"); //Image voiture 3
image(img, 950, height-(height/6)*3);
} else {
if (height-(height/6)<=mouseY&&mouseY<=height) {
cursor(HAND);
} else {
cursor(ARROW);
}
fill(#0FBF00);
rect(0, height-(height/6), width, height/6);
fill(#000000);
text("LANCER LE CHRONO", (width/5)-10, height-height/20);
}
}
void mousePressed() {
if (mouseButton == LEFT) {
if (height-(height/6)<=mouseY&&mouseY<=height) {
chrono() ;
tour(4);
} else if (100<=mouseX&&mouseX<=400&& height-(height/6)*3<=mouseY&&mouseY<=(height-(height/6)*3)+168&&tmpsstart!=0) {
tour(1);
} else if (525<=mouseX&&mouseX<=800&& height-(height/6)*3<=mouseY&&mouseY<=(height-(height/6)*3)+183&&tmpsstart!=0) {
tour(2);
} else if (950<=mouseX&&mouseX<=1209&& height-(height/6)*3<=mouseY&&mouseY<=(height-(height/6)*3)+194&&tmpsstart!=0) {
tour(3);
}
}
}
void mouse() {
if (height-(height/6)<=mouseY&&mouseY<=height) {
cursor(HAND);
} else if (100<=mouseX&&mouseX<=400&& height-(height/6)*3<=mouseY&&mouseY<=(height-(height/6)*3)+168&&tmpsstart!=0) {
cursor(HAND);
} else if (525<=mouseX&&mouseX<=800&& height-(height/6)*3<=mouseY&&mouseY<=(height-(height/6)*3)+183&&tmpsstart!=0) {
cursor(HAND);
} else if (950<=mouseX&&mouseX<=1209&& height-(height/6)*3<=mouseY&&mouseY<=(height-(height/6)*3)+194&&tmpsstart!=0) {
cursor(HAND);
} else {
cursor(ARROW);
}
}
void chrono() {
if (tmpsstart==0) {
background(#FFFFFF);
tmpsstart = millis();
} else {
tmpsstart=0;
}
}
void tour(int i) {
if (i==1) { // voiture 1
amili1=mili1;
mili1 = millis();
atour1 = tour1;
if (amili1==0)tour1=(mili1-tmpsstart);
else tour1=(mili1-amili1);
int ms=(tour1/60000);
int ss=((tour1/1000)-ms*60);
int mils=(tour1-(ss*1000));
String m=nf(ms, 2);
String s=nf(ss, 2);
String mil=nf(mils/10, 2);
chrono1=m;
chrono1+=" : ";
chrono1+=s;
chrono1+=" : ";
chrono1+=mil;
if (tour1<best1&&best1!=0) {
best1=tour1;
bests1=chrono1;
} else if (best1==0) {
best1=tour1;
bests1=chrono1;
}
} else if (i==2) { // voiure 2
amili2=mili2;
mili2 = millis();
atour2 = tour2;
if (amili2==0)tour2=(mili2-tmpsstart);
else tour2=(mili2-amili2);
int ms=(tour2/60000);
int ss=((tour2/1000)-ms*60);
int mils=(tour2-(ss*1000));
String m=nf(ms, 2);
String s=nf(ss, 2);
String mil=nf(mils/10, 2);
chrono2=m;
chrono2+=" : ";
chrono2+=s;
chrono2+=" : ";
chrono2+=mil;
if (tour2<best2&&best2!=0) {
best2=tour2;
bests2=chrono2;
} else if (best2==0) {
best2=tour2;
bests2=chrono2;
}
} else if (i==3) { // voiure 3
amili3=mili3;
mili3 = millis();
atour3 = tour3;
if (amili3==0)tour3=(mili3-tmpsstart);
else tour3=(mili3-amili3);
int ms = (tour3 /60000);
int ss = ((tour3 /1000)-ms*60);
int mils = (tour3-(ss*1000));
String m = nf(ms, 2);
String s = nf(ss, 2);
String mil = nf(mils/10, 2);
chrono3 = m;
chrono3+=" : ";
chrono3+=s;
chrono3+=" : ";
chrono3+=mil;
if (tour3<best3&&best3!=0) {
best3=tour3;
bests3=chrono3;
} else if (best3==0) {
best3=tour3;
bests3=chrono3;
}
} else if (i==4) { // Stop
amili1 = 0;
mili1 = 0;
tour1 = 0;
atour1 = 0;
chrono1 = "00 : 00 : 00";
best1=0;
bests1 = "00 : 00 : 00";
amili2 = 0;
mili2 = 0;
tour2 = 0;
atour2 = 0;
chrono2 = "00 : 00 : 00";
best2=0;
bests2 = "00 : 00 : 00";
amili3 = 0;
mili3 = 0;
tour3 = 0;
atour3 = 0;
chrono3 = "00 : 00 : 00";
best1=0;
bests3 = "00 : 00 : 00";
total = "";
}
}
void total() {
int tmp=(millis()-tmpsstart); // calcul du temps passé entre le début (tmpsstart) et maintenant (mili)
int ms = (tmp /60000);
int ss = ((tmp /1000)-ms*60);
int mils = (tmp-ss*1000-ms*60000);
String m = nf(ms, 2);
String s = nf(ss, 2);
String mil = nf(mils/10, 2);
total = m;
total+=" : ";
total+=s;
total+=" : ";
total+=mil;
}