急需一个C语言打字游戏代码,要求单词从屏幕上方落下,打字正确的字母变绿。

# include & lttime.h & gt

# include & ltstdlib.h & gt

# include & ltgraphics.h & gt

# include & ltconio.h & gt

# include & ltdos.h & gt

# include & ltmath.h & gt

#定义R 10

#定义ESC 0x011b

#定义低电平0x5000

#定义快速0x4800

int draw_car(int x,int y,char * ch);

双dalta = 20,角度;

void * image

int step = 20

主()

{

int gdriver=DETECT,gmode

静态int startx = 60

静态int starty = 20

int maxy,maxx,l=1,n = 1;

char ch,play,str[2];

int size,temch

int ok,y = 50

clr SCR();

printf(" \ n \ n \ n \ n \ n * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");

printf(" 1 .只播放数字0-9。\ n ");

printf(" 2 .只播放char a-z。\ n ");

printf(" 3 . exit \ n ");

printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");

while(1){

printf(" \ n请输入选项:");

play = getche();

if((play = = ' 1 ')| |(play = = ' 2 '))

打破;

if(play=='3 ')

返回;

}

registerbgidriver(EGA VGA _ driver);/*寄存器vga驱动程序*/

init graph(& amp;g driver & amp;gmode," d:\ \ tc3 \ \ bgi ");/*初始化图形界面*/

clear device();/*清空屏幕*/

setbkcolor(蓝色);/*将背景颜色设置为蓝色*/

size=imagesize(startx,starty,startx+60,starty+60);/*计算生成60×60像素的图形所需的字节数*/

image =(unsigned char *)malloc(size);/*分配内存*/

maxx = get maxx();

maxy = get maxy();

randomize();

printf("按ESC退出游戏!");

printf(" %c为快速,%c为低速!",24,25);

做{

ok = 0;

if(play=='1 ')

ch = random(9)+48;

if(play=='2 ')

ch = random(26)+65;

str[0]= ch;

做{

While(bioskey(1)==0) /*如果没有按钮,会一直循环*/

{

If(l==1) /*从左到右*/

{

n++;

角度=-1 *(n *步)/M _ PI * 180/R;

if((int)(-1 * angle)% 360 & lt;达尔塔)

角度-= dalta;

如果(n & gt(maxx-180)/步骤){

if(starty & gt;maxy-100)

starty = 20

其他

starty+= y;

l = 0;

}

}

If(l==0) /*从右向左*/

{

-n;

角度=-1 *(n *步)/R/M _ PI * 180;

if((int)(-1 * angle)% 360 & lt;达尔塔)

角度-= dalta;

if(n==1){

if(starty & gt;maxy-100)

starty = 20

其他

starty+= y;

l = 1;

}

}

draw_car(startx+n*step,starty,str);

}

temch = BIOS key(0);

if(temch==FAST){

步长+= 10;

y+= 10;

}

if(temch==LOW){

step-= 10;

y-= 10;

}

ok = temch & amp0x 00 ff;

if((ok==ch)||(ok==ch+32)){

ok = 1;

starty = 20

打破;

}

}while(temch!= ESC);

如果(好!=1)

打破;

} while(1);

免费(图片);

closegraph();

返回;

}

int draw_car(int x,int y,char *ch){

setcolor(黄色);/*将前景色设置为黄色*/

矩形(x,y,x+60,y+40);/*画一辆马车*/

pieslice(x+15,y+50,angle,angle-dalta,10);/*绘图轮上的一个小扇形*/

pieslice(x+45,y+50,angle,angle-dalta,10);

setfillstyle(SOLID_FILL,黄色);/*设置填充模式为纯色填充,颜色为黄色*/

圆(x+15,y+50,10);/*画一个轮子*/

圆(x+45,y+50,10);

圆(x+15,y+50,3);

圆(x+45,y+50,3);

setcolor(白色);

settextstyle(1,0,4);

outtextxy(x+25,y,ch);

getimage(x,y,x+60,y+60,image);/*获取当前图片*/

延迟(200);

putimage(x,y,image,XOR _ PUT);/*使用XOR模式显示图片*/

返回;

}