#include "stdio.h"
#include "conio.h"
#include "time.h"
#include "stdlib.h"
#include "graphics.h"
#include "math.h"
#define PI 3.14
main()
{
float i ,j ,k = -2;
int gd=DETECT ,gm;
int Mx ,My , xd = 1, yd = 1 ,kd = 1 ,cr = 1 ,cd = 1;
float x = 0 ,y = 0 ,xm = 0 ,ym = 0;
initgraph(&gd ,&gm ,"");
Mx = getmaxx()/2;
My = getmaxy()/2;
while(!kbhit())
{
for(i = 0;i < PI;i+=0.05)
{
for(j = 0;j < PI ;j+=0.05)
{
x = cos(i+k)*30*j+Mx+xm;
y = sin(j+k)*30*i+My+ym;
putpixel(x ,y ,cr);
}
}
xd = (xm > 200)? -1: xd;
xd = (xm < -200)? 1: xd;
yd = (ym > 250)? -1: yd;
yd = (ym < -250)? 1: yd;
kd = (k > PI*2)? -1: kd;
kd = (k < -PI*2)? 1: kd;
cd = (cr > 11)? -1: cd;
cd = (cr < 5)? 1: cd;
k += 0.1*kd;
xm += 2*xd;
ym += 2*yd;
cr += 4*cd;
delay(10000);
cleardevice();
}
getch();
}
写的有点乱
[此贴子已经被作者于2007-1-29 15:56:21编辑过]