// chessclock
// (c) Thad 2000
// http://thad.notagoth.org/contact/
string msg,side[2];
main()
{
int count,start;
int t,ot,n;
int p,players[2];
side[0]="White";
side[1]="Black";
graph_on();
textattr(7,1,0);
textalign(11);
rect(0,0,0,160,160,0);
text(80,80,"...chessclock...");
players[0]=
players[1]=
60*(int)gets("minutes?");
while(1)
for(p=0;p < 2;p++){
n=count=players[p];
ot=start=seconds();
t=0;
while(event(0)!=3 && n > 0){
t=seconds();
if(t > ot){
while(ot++ < t){
n=count-(ot-start);
rect(3,
(n%10)*16,144*p,
(n%10)*16 + 15,144*p+15,0);
}
ot=t;
msg = side[p]+": "+
format(
(n/60)+(n%60)*0.01,2
);
text(80,40+(80*p),msg);
}
else sleep(50);
}
beep(1);
players[p]=n;
if (n<=0){
msg=side[p] + " out of time! ";
text(80,40+(80*p),msg);
beep(1);beep(2);beep(5);
waitp();exit();
}
}
}
|
|