#include <graphics.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#define PI 3.14159
#define maxx 640
#define maxy 480
main()
{int i;
char c;
init();
draw();
c=getch();
}
init()
/*初始化图形系统函数*/
{int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"c:\\tc\\bgi"); /*注意此处的路径*/
setbkcolor(1);
sky();
return;
}
sky()
{int x,y,i;
for(i=1;i<=500;i++)
{x=rand()%640;y=rand()%300;
putpixel(x,y,15);
putpixel(x+1,y,15);
}
for(i=1;i<=200;i++)
{x=rand()%640;y=300+rand()%100;
putpixel(x,y,15);
}
return;
}
draw()
{int i,j,k,x,y,dy;
setfillstyle(1,7);
for(i=1;i<=10;i++)
{setlinestyle(3,0,3);
x=100+rand()%400;dy=20+rand()%20;
for(k=1000;k>=500;k-=100)
{sound(k);delay(3000);}
nosound();
for(j=1;j<=10;j++)
{setcolor(i%16);
line(x,maxy-(j-1)*dy,x,maxy-j*dy);
delay(10000);
setcolor(0);
line(x,maxy-(j-1)*dy,x,maxy-j*dy);
}
for(k=6000;k>=3000;k-=100)
{sound(k);delay(20000);}
nosound();
setlinestyle(3,0,2);
drawellipse(x,maxy-(j-1)*dy);
}
return;
}
drawellipse(int x,int y)
{int i,j,x1,y1,a,b;
float q;
a=60+rand()%60;b=a-rand()%60;
for(i=2;i>=0;i--)
{
for(q=0;q<=2*PI;q+=0.12)
{setcolor(rand()%16);
x1=x+(a-i*30)*cos(q);
y1=y-(b-i*30)*sin(q);
line(x,y,x1,y1);
}
delay(50000);
setcolor(0);
for(q=0;q<=2*PI;q+=0.12)
{x1=x+(a-i*30)*cos(q);
y1=y-(b-i*30)*sin(q);
line(x,y,x1,y1);
}
}
return;
}