C语言输出图形自动移动

来源:百度知道 编辑:UC知道 时间:2024/05/27 05:14:27
#include "bios.h"
#include "conio.h"
#include "stdlib.h"
main()
{
int key;
int i,j;
struct move_point
{int x,xv;
int y,yv;};
struct move_point man={1,1,1,1};
gotoxy(1,1);
for(i=man.x;i<80;i++)
{printf(" ");
gotoxy(man.x,man.y);
textcolor(RED);
putch(2);
printf("\b");
man.x=man.x+1;}
}
要在哪里添加什么代码才能实现特定的时间移动一步,不然 根本看不到移动的过程,直接就从1,1到81,1了

Sleep函数,让他歇菜一会儿,就在循环体里面加,前面后面随意。但是不同系统不同编译器的Sleep函数不一样,你自己看看吧。

能让我看一下你的gotoxy函数吗?我也想学一下^^

自己实现sleep()
----------------------------------------------------------------------------------------------------
void sleep()
{
int i,j,k;
for(i=0;i<30000;i++)
for(j=0;j<30000;j++)
for(k=0;k<30000;k++)
;
}

gotoxy是标准库函数
----------------------------------------------------------------------------------------------------
原型:extern void gotoxy(int x, int y);
用法:#include <system.h>
功能:将光标移动到指定位置说明:gotoxy(x,y)将光标移动到指定行y和列x。
gotoxy(0,0)将光标移动到屏幕左上角
举例:
#include <system.h>
main()
{
int i;
char *scrbuf=(char *)0x280;
for(i=0;i<85;i++) scrbuf='+';
UpdateLCD(0x00);
gotoxy(2,2);
getchar();
move(2,2);
getchar();
return 0;
}