level 6
gertt
楼主
/* WIN-TC BGI 图形编程模板 */
#include "Conio.h"
#include "graphics.h"
#define closegr closegraph
void initgr(void) /* BGI初始化 */
{
int gd = DETECT, gm = 0; /* 和gd = VGA,gm = VGAHI是同样效果 */
registerbgidriver(EGAVGA_driver);/* 注册BGI驱动后可以不需要.BGI文件的支持运行 */
initgraph(&gd, &gm, "");
}
int main(void)
{
char a;
int x,y,xx,yy,cx,cy;
x=y=xx=yy=cx=cy=0;
initgr(); /* BGI初始化 */
M:
cleardevice();
setcolor(3);
line(xx, yy, x, y);
circle(cx, cy, 5);
a=getch(); /* 暂停一下,看看前面绘图代码的运行结果 */
if(a=='a')
cx--;
if(a=='w')
cy--;
if(a=='s')
cy++;
if(a=='d')
cx++;
if(a=='x')
exit(0);
if(a=='q')
{
xx=cx;yy=cy;
}
if(a=='e')
{
x=cx;y=cy;
}
goto M;
closegr(); /* 恢复TEXT屏幕模式 */
return 0;
}
2011年05月21日 16点05分
1
#include "Conio.h"
#include "graphics.h"
#define closegr closegraph
void initgr(void) /* BGI初始化 */
{
int gd = DETECT, gm = 0; /* 和gd = VGA,gm = VGAHI是同样效果 */
registerbgidriver(EGAVGA_driver);/* 注册BGI驱动后可以不需要.BGI文件的支持运行 */
initgraph(&gd, &gm, "");
}
int main(void)
{
char a;
int x,y,xx,yy,cx,cy;
x=y=xx=yy=cx=cy=0;
initgr(); /* BGI初始化 */
M:
cleardevice();
setcolor(3);
line(xx, yy, x, y);
circle(cx, cy, 5);
a=getch(); /* 暂停一下,看看前面绘图代码的运行结果 */
if(a=='a')
cx--;
if(a=='w')
cy--;
if(a=='s')
cy++;
if(a=='d')
cx++;
if(a=='x')
exit(0);
if(a=='q')
{
xx=cx;yy=cy;
}
if(a=='e')
{
x=cx;y=cy;
}
goto M;
closegr(); /* 恢复TEXT屏幕模式 */
return 0;
}