[原创]转动的轮子(c语言)
/*大家将会看到一个轮子在转动*/#include<graphics.h>
main()
{
int driver=9,mode=2;
int i=0,stangle=0,endangle=0;
initgraph(&driver,&mode,"");
cleardevice();
setcolor(5);
circle(60,60,50);
outtextxy(100,100,"please press any key");/*进程提示*/
getch();
cleardevice();
outtextxy(150,150,"please press any key");/*输出文本*/
while(i<=520)/*产生从左到右的圆圈*/
{
circle(60+i,60,50);
delay(6000);/*延迟6000ms*/
cleardevice();
i++;
}
outtextxy(100,100,"if you want to stop,");
outtextxy(100,150,"please press any key");
getch();
while(!kbhit())/*按任意键停止*/
{
cleardevice();
setbkcolor(6);
setfillstyle(1,3);
floodfill(61+i,60,6);
i=0;
while(i<=520)/*产生从左到右运动的轮子*/
{
stangle=i*45;
endangle=(i+1)*45;
circle(60+i,60,50);
pieslice(60+i,60,stangle,endangle,50);
delay(600);
i++;
cleardevice();
}
floodfill(570,61+i,6);
i=0;
while(i<=300)/*从上到下的轮子*/
{
stangle=i*45;
endangle=(i+1)*45;
circle(570,60+i,50);
pieslice(570,60+i,stangle,endangle,50);
delay(600);
i++;
cleardevice();
}
floodfill(i+1,380,6);
i=570;
while(i>=60)/*从右到左的轮子*/
{
stangle=i*45;
endangle=(i+1)*45;
circle(i,380,50);
pieslice(i,380,stangle,endangle,50);
delay(600);
i--;
cleardevice();
}
floodfill(60,381-i,6);
i=0;
while(i<=300)/*从下到上的轮子*/
{
stangle=i*45;
endangle=(i+1)*45;
circle(60,380-i,50);
pieslice(60,380-i,stangle,endangle,50);
delay(600);
i++;
cleardevice();
}
}
getch();
closegraph();
}