一个经典的打字小游戏

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

while(1); } void dazi::help() { system("cls"); cout<<"\n\n\n\n"<<endl; cout<<"\n\t\t\t********************"<<endl; cout<<"\n\t\t\t* *"<<endl; cout<<"\n\t\t\t* *生¦¨²活?如¨?此ä?* *"<<endl; cout<<"\n\t\t\t* *简¨°简¨°单Ì£¤单Ì£¤* *"<<endl; cout<<"\n\t\t\t* *"<<endl; cout<<"\n\t\t\t********************\n\n\n\n\n\n\n\t\t\t"<<endl; system("pause"); } void dazi::about() { system("cls"); cout<<"\n"<<endl; cout<<"\n\t\t\t*************************************"<<endl; cout<<"\n\t\t\t* 欢?迎®-进?入¨? 小?u丶?的Ì?空?间? *"<<endl; cout<<"\n\t\t\t*************************************"<<endl; cout<<"\n\t\t\t*||||||||||||||||||||||||||||||||||*"<<endl; cout<<"\n\t\t\t* *"<<endl; cout<<"\n\t\t\t* —a—a—a—a—a—a—a—a—a—a—a—a—a—a—a—a—a*"<<endl; cout<<"\n\t\t\t*http://user.qzone.qq.com/752290963 *"<<endl; cout<<"\n\t\t\t* —a—a—a—a—a—a—a—a—a—a—a—a—a—a—a—a—a*"<<endl; cout<<"\n\t\t\t* *"<<endl; cout<<"\n\t\t\t*|||||||||||||||||||||||||||||||||| *"<<endl; cout<<"\n\t\t\t*************************************"<<endl; cout<<"\n"<<endl; system("pause"); } int { system("cls"); cout<<"\n\n\n\n\n\t\t\t\tWElCOME GAME...\n\n\n\n\n"<<endl; for(int i=0;i<80;i++) { cout<<">"; Sleep(20); }; return 0; } void { { system("cls"); cout<<"\n\n\n\n\n\n\n\n\n\n\t\t\t进?入¨?游®?戏¡¤中D"; dazi::select() for(int i=0;i<2;i++)
dazi::time()
for(int j=0;j<10;j++) { Sleep(30); cout<<"."; } } do { system("cls"); cout<<"\n"<<endl; cout<<"\n\t\t\t*********************************"<<endl; cout<<"\n\t\t\t* 请?选?择?难?度¨¨系¦Ì数ºy *"<<endl; cout<<"\n\t\t\t*********************************"<<endl; //cout<<"\n\t\t\t* *"<<endl; cout<<"\n\t\t\t* *"<<endl; cout<<"\n\t\t\t* 1.简¨°单Ì£¤ *"<<endl; cout<<"\n\t\t\t* 2.一°?般ã? *"<<endl; cout<<"\n\t\t\t* 3.较?难? *"<<endl; cout<<"\n\t\t\t* 4.返¤¦Ì回? *"<<endl; cout<<"\n\t\t\t* *"<<endl; cout<<"\n\t\t\t*********************************"<<endl; cout<<"\n\t\t\t请?选?择?:"; int i; cin>>i; switch(i) { case 1: time(); start(); body(160); break; case 2: time(); start(); body(120); break; case 3: start(); body(60); break; case 4: //Sleep(0); welcome(0.000000000001); break; default: cout<<"您¨²的Ì?输º?入¨?有®D误¨®!按ã¡ä任¨?意°a键¨¹继¨¬续?......"; getchar(); getchar(); } }while(1);
wk.baidu.com
{ k=getch(); //getch() 包㨹含?在¨²<conio.h> if(k==ch||k==ch+32) { cok++; break; } } show.setxy(x,y); cout<<ch; sleep(s); show.setxy(x,y); cout<<' '; y++; } show.setxy(0,h+1); cout<<"*** GOOD —a—a—a—a—a—a—a—a—a—a—a—a—a—a—a—a GOOD ***"<<endl; cout<<cok<<"/"<<c<<" "<<cok*1.0/c*100<<"%"<<" "<<endl; cout<<"*** GOOD —a—a—a—a—a—a—a—a—a—a—a—a—a—a—a—a GOOD ***"<<endl; if(cok*1.0/c*100<0.5) cout<<" 这a样¨´不?行D,ê?还1得Ì?努?力¢|!!!"; else if(cok*1.0/c*100==1) cout<<" 真?棒ã?!ê?再¨´接¨®再¨´厉¤¡Â!ê?!ê?!ê?"; } //return cok; //return c; return 0; } void dazi::end() { system("cls"); cout<<"\n\n\n\n"<<endl; cout<<"\n\t\t\t********************"<<endl; cout<<"\n\t\t\t* *"<<endl; cout<<"\n\t\t\t* 感D谢?您¨²的Ì?使º1用®?! *"<<endl; cout<<"\n\t\t\t* Goodbye! *"<<endl; cout<<"\n\t\t\t* *"<<endl; cout<<"\n\t\t\t********************\n\n\n\n\n\n\n\t\t\t"<<endl; system("pause"); } int main() { //dazi A; //dazi B; system("cls"); dazi W; W.welcome(60);
*\n";
} void { dazi::setxy(int x,int y)
COORD coord; coord.X=x; coord.Y=y; SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), coord ); // COORD point类¤¨¤型¨ª //SetConsoleCursorPosition是º?API中D定¡§位?光a标À¨º位?置?的Ì?函¡¥数ºy。 ¡ê包㨹含? 在¨² <windows.h> } void sleep(unsigned int mseconds)//包㨹含?于®¨² windows.h 延¨®时º¡À函¡¥数ºy { clock_t goal = mseconds + clock(); while (goal > clock()); } int dazi::body(int s) { dazi show; int h=20; int w=40; int x,y; int c=0,cok=0; char ch, k; while(1) { ch=rand()%26+'A'; x=10+rand()%w; y=5; c++; while(y<h) { if(_kbhit()) // _kbhit()功| 能¨¹及¡ã返¤¦Ì回?值¦Ì:êo 检¨¬查¨¦当Ì¡À前¡ã是º?否¤?有®D 键¨¹盘¨¬输º?入¨?,ê?若¨?有®D则¨°返¤¦Ì回?一°?个?非¤?0值¦Ì,ê?否¤?则¨°返¤¦Ì回?0 包㨹含?在¨² <conio.h>
#include <iostream> #include <windows.h> #include <time.h> #include <conio.h> using namespace std; class dazi { public: void void int void void void void int void }; void setxy(int x,int y); welcome(float s); body(int s); start(); about(); select(); end(); time(); help();
dazi::welcome(float s)
{ for(int i=0;i<3;i++) { system("cls"); cout<<"\n\n\n\n\n\n\n\n\n\n\t\t\t正y在¨²进?入¨?请?稍¦?后¨®"; for(int j=0;j<10;j++) { Sleep(s); cout<<"."; } } do { system("cls"); cout<<"\n"<<endl; cout<<"\n\t\t\t*********************************"<<endl; cout<<"\n\t\t\t* 欢?迎®-挑¬?战? *"<<endl; cout<<"\n\t\t\t*********************************"<<endl; //cout<<"\n\t\t\t* *"<<endl; cout<<"\n\t\t\t* *"<<endl; cout<<"\n\t\t\t* 1.进?入¨?游®?戏¡¤ *"<<endl; cout<<"\n\t\t\t* 2.游®?戏¡¤指?南? *"<<endl; cout<<"\n\t\t\t* 3.关?于®¨²作Á¡Â者? *"<<endl; cout<<"\n\t\t\t* 4.退ª?出? *"<<endl; cout<<"\n\t\t\t* *"<<endl; cout<<"\n\t\t\t*********************************"<<endl; cout<<"\n\t\t\t请?选?择?:"; int i; cin>>i; switch(i) { case 1: select(); break; case 2: help(); break; case 3: about(); break; case 4: //Sleep(300); end(); exit(0); break; default: cout<<"您¨²的Ì?输º?入¨?有®D误¨®!按ã¡ä任¨?意°a键¨¹继¨¬续?......"; getchar(); //getchar(); } }
} void {
dazi::start() system("cls"); int i; for(i=1;i<=2;i++) { cout<<" |"<<endl; cout<<" *"<<endl; } cout<<"*** ZYH *** "; for(i=9;i<=13;i++) cout<<"- * - "; cout<<" GOOD *** "<<endl; for(i=1;i<=8;i++) cout<<" |"<<endl<<"
相关文档
最新文档