#include#include "conio.h"
#include"math.h"
void main()
{
int gdriver=DETECT,gmode; /*图形模式设定*/
char f;
int m,n,x,y,t;
int color;
x=320;y=240;
m=0;n=0;
initgraph(&gdriver,&gmode,"c: \\tc");
printf("qweadzxc stand for eight direction,p to exit,and the number stand for color when paint\n");
printf("input anykey to start\n");
getch();
printf("PLEASE INPUT THE COLOR\n");
scanf("%d",&color);
loop:
while(!kbhit())
{
putpixel(x,y,color);
x=x+m;y=y+n;
for(t=0;t<=50;t++)
delay(100);
}
f=getch();
if(f=='w'||f=='W')
{
m=0;n=-1;
goto loop;
}
if(f=='x'||f=='X')
{
m=0;n=1;
goto loop;
}
if(f=='a'||f=='A')
{
m=-1;n=0;
goto loop;
}
if(f=='d'||f=='D')
{
m=1;n=0;
goto loop;
}
if(f=='q'||f=='Q')
{
m=-1;n=-1;
goto loop;
}
if(f=='e'||f=='E')
{
m=1;n=-1;
goto loop;
}
if(f=='z'||f=='Z')
{
m=-1;n=1;
goto loop;
}
if(f=='c'||f=='C')
{
m=1;n=1;
goto loop;
}
if(f==' ')
{
m=0;n=0;
getch();
goto loop;
}
if(f=='p'||f=='P')
goto end;
if(f=='s'||f=='S')
{
printf("please input the color you want to set\n");
scanf("%d",&color);
goto loop;
}
else
{
printf("ERROR!\n");
goto loop;
}
end:
getch();
closegraph(); /*退出图形模式*/
}