#include
#include
#include
#include
void fan(), rotation();
int x=0,speed=250;
// ----- Program begins here
void main()
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"");
fan();
getch();
}//End of main function
// ----- function to design the fan
void fan()
{
int i;
setfillstyle(SOLID_FILL,15);
circle(320,240,100); circle(320,240,98);
pieslice(320,240,0,360,10);
bar(310,340,330,360);
rectangle(270,360,370,400);
line(280,330,310,360);
line(330,360,360,330);
outtextxy(450,10,"[ 0 ] Stop");
outtextxy(450,20,"[ 1 ] Slow");
outtextxy(450,30,"[ 2 ] Medium");
outtextxy(450,40,"[ 3 ] Fast");
outtextxy(400,450,"Developed by Kailas, S7 CS, MCET");
rotation();
}
// ----- function to rotate the fan
void rotation()
{
int f1=360,f2=240,f3=120;
int i;
char c;
setcolor(0);
while(1)
{
if(kbhit()) //to detect whether there is any key stroke
{
c=getch();
if(c=='0') // if key pressed is x or X then exit
{
exit(0);
}
else if(c=='1') // minimun speed
speed=250;
else if(c=='2') // medium speed
speed=100;
else if(c=='3') // maximum speed
speed=50;
}
setfillstyle(SOLID_FILL, 0);
sector(320,240,f1,f1+20,70,70);
sector(320,240,f2,f2+20,70,70);
sector(320,240,f3,f3+20,70,70);
f1=f1-30;
f2=f2-30;
f3=f3-30;
if(f1<=30)
f1=360;
if(f2<=30)
f2=360;
if(f3<=30)
f3=360;
setfillstyle(SOLID_FILL, 15);
sector(320,240,f1,f1+20,70,70);
sector(320,240,f2,f2+20,70,70);
sector(320,240,f3,f3+20,70,70);
pieslice(320,240,0,360,10);
delay(speed);
}
}
/*------------------------------ END --------------------------------------*/
No comments:
Post a Comment