#include #include #include #include #include "polygon.h" void setgraph(); void main() { char dummy; int MAX_X, MAX_Y; int hour, minute, second,hourdiff,mindiff; time_t t1, t2; tm gmt,old; Polygon big("arrow.dat"); // calls constructor Polygon little=big; // calls copy constructor Polygon sec=big; // calls copy constructor little.scale(1.5,0.7); sec.scale(0.3,1.05); setgraph(); MAX_X = getmaxx(); MAX_Y = getmaxy(); big.scale(MAX_Y/2.0,MAX_Y/2.0); little.scale(MAX_Y/2.0,MAX_Y/2.0); sec.scale(MAX_Y/2.0,MAX_Y/2.0); big.translate(MAX_X/2.0,MAX_Y/2.0); little.translate(MAX_X/2.0,MAX_Y/2.0); sec.translate(MAX_X/2.0,MAX_Y/2.0); t1 = time(NULL); gmt = *(localtime(&t1)); hour = gmt.tm_hour; minute = gmt.tm_min; second = gmt.tm_sec; circle(MAX_X/2,MAX_Y/2,MAX_Y/2); big.rotate(-6*minute); little.rotate(-(30*hour+minute/2)); sec.rotate(-6*second); big.draw(); little.draw(); sec.draw(); while (true) { t1 = time(NULL); t2=t1; while(difftime(t2,t1) < 1) { t2 = time(NULL); } old = gmt; gmt = *(localtime(&t1)); hourdiff = gmt.tm_hour-old.tm_hour; mindiff = gmt.tm_min-old.tm_min; big.rotate(-6*(mindiff)); little.rotate(-(30*hourdiff+mindiff/2)); sec.rotate(-6); clearviewport(); circle(MAX_X/2,MAX_Y/2,MAX_Y/2); big.draw(); little.draw(); sec.draw(); } cin >> dummy;; closegraph(); } void setgraph() { char dummy; int gdriver = DETECT, gmode, errorcode; initgraph(&gdriver,&gmode,"c:\\bc5\\bgi"); errorcode = graphresult(); if (errorcode != grOk) { cerr << "Error: " << grapherrormsg(errorcode); cout << "Press any key to halt: "; cin >> dummy; exit(1); } }