blindfish wrote on Jun 17th, 2009, 2:45pm:Hmmm... That's a slightly unconventional stopwatch, but I guess you may have a reason to count in fives...
Anyway - it's not a bad first attempt, but you do have a slight problem: the top counter continues to increase when the stopwatch is 'paused'. Pause and wait a few seconds then restart and you'll see what I mean.
thank you for you advice.
i know what you mean.
so i have changed code:
int ss;
int ii=1;
int mill;
int a;
int b;
int m;
int s;
int u;
int v;
void setup(){
PFont font;
font = loadFont("ArialNarrow-12.vlw");
textFont(font);
size(600,600);
ss=0;
}
void draw(){
background(255);
if(ii==0){
mill=(millis()-ss)/1000;
m=mill/5+u;
s=mill%5+v;
a=m;
b=s;
//p=0;
// println(a);
//println(b);
}
if(ii==2){
mill=(millis()-ss)/1000;
m=mill/5;
s=mill%5;
a=m;
b=s;
}
fill(0,0,0);
text(a,50,100); // a is minute
text("m",60,100);
text(b,50,120); // b is second
text("s",60,120);
text("key b for begin,s for stop, c for continue",50,140);
}
void keyPressed(){ //watch stop
if(key=='s'){
ii=1;
}
if(key=='b'){ //watch beginn or reneu
ii=2;
ss=millis();
}
if(key=='c'){ //watch continue
ii=0;
ss=millis();
u=a;
v=b;
}
}