c语言写的飞天打字游戏含源代码

时间:2014-03-25 17:18:16
【文件属性】:

文件名称:c语言写的飞天打字游戏含源代码

文件大小:2KB

文件格式:C

更新时间:2014-03-25 17:18:16

打字游戏

学习语言写的第一个游戏,不足之处请包涵 #include"stdio.h" #include"Conio.h" #include"stdlib.h" char words[3][10]={{'q','w','e','r','t','y','u','i','o','p'}, {'a','s','d','f','g','h','j','k','l',';'}, {'z','x','c','v','b','n','m',',','.','/'}}; int score=0; int i; int j; int press=-1; int main() { int i=1; int j=1; int word=0; int step=1; int speed=60000; PrintfW(); while(word!=27) { press+=1; if(press%100==0) speed-=10000; randomize(); Score(); step=0; i=rand()%10; j=rand()%3; while(!kbhit()) { PrintfW(); gotoxy(i+4*i+3,j+3+step); printf("%c",words[j][i]); delay(speed); gotoxy(i+4*i+3,j+3+step); printf(" "); step+=1; if((j+3+step)==24) { score-=1; Score(); break; } } word=getch(); if((word==words[j][i])||(word==(words[j][i])-32)) { score+=1; Score(); } else if(word!=words[j][i]) { score-=1; Score(); } } return 0; } PrintfW() { window(2,2,58,24); textbackground(BLUE); textcolor(LIGHTRED); clrscr(); for(j=0;j<3;j++) { for(i=0;i<10;i++) { gotoxy(i+4*i+3,j+3); printf("%c",words[j][i]); } printf("\n"); } } Score() { window(60,1,80,25); textbackground(LIGHTGRAY); textcolor(BROWN); clrscr(); gotoxy(2,2); printf("Word V1,2"); gotoxy(2,6); printf("Write by:Yuzubo"); gotoxy(4,8); printf("2010.11.11"); gotoxy(3,11); printf("your score:%d",score); gotoxy(4,15); printf("your press:%d",press); } 


网友评论

  • 有点复杂,初学者不太懂