关于做图
在easyx库下 比如:字符A 从屏幕顶端移动到底端(直线移动或者随机降落) 那么这个A 到底部后 还是最初的A吗 是A一直在移动 还是在不停的刷屏 不断的产生新
A
程序代码:
#include <graphics.h>
#include <time.h>
#include <conio.h>
int main(void)
{
// 设置随机函数种子
srand((unsigned) time(NULL));
// 初始化图形模式
initgraph(640, 480);
// 设置背景色为蓝色
setbkcolor(BLUE);
// 用背景色清空屏幕
cleardevice();
// 设置绘图色为红色
setcolor(RED);
setfont(36, 18, L"Courier");
for(int row=5;row<450;row+=20)
{
outtextxy(rand()%630,row,rand()%93+33);
outtextxy(rand()%630,row,rand()%93+33);
outtextxy(rand()%630,row,rand()%93+33);
outtextxy(rand()%630,row,rand()%93+33);
outtextxy(rand()%630,row,rand()%93+33);
outtextxy(rand()%630,row,rand()%93+33);
outtextxy(rand()%630,row,rand()%93+33);
outtextxy(rand()%630,row,rand()%93+33);
outtextxy(rand()%630,row,rand()%93+33);
outtextxy(rand()%630,row,rand()%93+33);
outtextxy(rand()%630,row,rand()%93+33);
outtextxy(rand()%630,row,rand()%93+33);
outtextxy(rand()%630,row,rand()%93+33);
outtextxy(rand()%630,row,rand()%93+33);
Sleep(1000);
cleardevice();
}
getch();
// 关闭图形模式
closegraph();
return 0;
}

程序代码:#include <graphics.h>
#include <time.h>
#include <conio.h>
int main(void)
{
int x=320,y=240,x_s=-6,y_s=2;
// 设置随机函数种子
srand((unsigned) time(NULL));
// 初始化图形模式
initgraph(640, 480);
// 设置背景色为蓝色
setbkcolor(BLUE);
// 用背景色清空屏幕
cleardevice();
// 设置绘图色为红色
setfont(36, 18, "Courier");
while(1)
{
setcolor(RED);
outtextxy(x,y,'A');
if(x+20>640||x<0)x_s=-x_s;
if(y+30>480||y<0)y_s=-y_s;
Sleep(100);
setcolor(BLUE);
outtextxy(x,y,'A');
x=x+x_s;
y=y+y_s;
}
getch();
// 关闭图形模式
closegraph();
return 0;
}