主题:来看一下
程序的用意是用光标键控制图形。按Esc键退出
#include<graphics.h>
#include<conio.h>
#include<bios.h>
#define LEN 3
main()
{
int gr=DETECT,gm,x=320,y=350,r=40;
int ch;
initgraph(&gr,&gm,"");
setcolor(BLUE);
circle(x,y,r);
while((ch=bioskey(0))!=0x11b)
{
setcolor(GREEN);
circle(x,y,r);
switch(ch)
{case 0x4800: y-=LEN;break;
case 0x5000: y+=LEN;break;
case 0x4b00: x-=LEN;break;
case 0x4d00: x+=LEN;break;
}
setcolor(BLUE);
circle(x,y,r);
}
restorecrtmode();
}
用光标键控制。如果你在第一个setcolor(BLUE);后加上floodfill(x,y,YELLOW);看一下另一个结果会是咋样。
#include<graphics.h>
#include<conio.h>
#include<bios.h>
#define LEN 3
main()
{
int gr=DETECT,gm,x=320,y=350,r=40;
int ch;
initgraph(&gr,&gm,"");
setcolor(BLUE);
circle(x,y,r);
while((ch=bioskey(0))!=0x11b)
{
setcolor(GREEN);
circle(x,y,r);
switch(ch)
{case 0x4800: y-=LEN;break;
case 0x5000: y+=LEN;break;
case 0x4b00: x-=LEN;break;
case 0x4d00: x+=LEN;break;
}
setcolor(BLUE);
circle(x,y,r);
}
restorecrtmode();
}
用光标键控制。如果你在第一个setcolor(BLUE);后加上floodfill(x,y,YELLOW);看一下另一个结果会是咋样。