out() { int key; key=bioskey(0); if(key==ESC) exit(0); }
void main(void)
{ int minx=40; int miny=40; int maxx=400; int maxy=400; int x,y; int cx,cy; int addx=1,addy=-1; x=(minx+maxx)/2; y=(miny+maxy)/2; int driver,mode; driver=DETECT; initgraph(&driver,&mode,""); rectangle(40,40,400,400);
while(1) { cx=x,cy=y; x=x+addx,y=addy+y; if(x<=minx+R+1||x>=maxx-R-1) addx=-addx; if(y<=miny+R+1||y>=maxy-R-1) addy=-addy; setcolor(BLACK); circle(cx,cy,R); delay(600); setcolor(WHITE); circle(x,y,R); if(bioskey(1)) out(); } } 我就是不懂错在哪里,希望各位能帮下我,我是初学的菜鸟
----------------解决方案--------------------------------------------------------
out() { int key; key=bioskey(0); if(key==ESC) exit(0); }
void main(void)
{ int minx=40; int miny=40; int maxx=400; int maxy=400; int x,y; int cx,cy; int addx=1,addy=-1; int driver,mode;//驱动变量和模式变量应该开始定义 x=(minx+maxx)/2; y=(miny+maxy)/2; driver=DETECT; initgraph(&driver,&mode,"");
while(1) {cleardevice(); rectangle(40,40,400,400); cx=x,cy=y; x=x+addx,y=addy+y; if(x<=minx+R+1||x>=maxx-R-1) addx=-addx; if(y<=miny+R+1||y>=maxy-R-1) addy=-addy; setcolor(BLACK); circle(cx,cy,R); delay(600); setcolor(WHITE); circle(x,y,R); if(bioskey(1)) out(); } } 我就是不懂错在哪里,希望各位能帮下我,我是初学的菜鸟
帮你修改好了,但是会一直闪!
----------------解决方案--------------------------------------------------------
PS:你的退出键不起作用,在程序最后最好再加一句closegraph();退出图形模式。
----------------解决方案--------------------------------------------------------
啊 哥哥 谢谢了
----------------解决方案--------------------------------------------------------