本文主要是介绍devc++跑酷游戏2.4.0,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
导航:
Dev-c++跑酷小游戏 1.0.0
devc++跑酷小游戏1.2.5
devc++跑酷游戏1.2.6
devc++跑酷游戏2.0.0
devc++跑酷游戏2.0.1
【更新内容(废话)】:
又更新了两关,用方格便利贴画地图真的超级方便
把'z'键的功能从重新开始刷新改成了只刷新,对经常不小心按到其他键的大手党更加友好和银杏化了(对,没错,我就是实在不想测试关卡快到终点时不小心按到刷新让后又要花十几分钟再跑一遍)
把代表人物的字符改成了一个变量存储,以后万一要改也更好改,devc++的替换真香!!!
正文:
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#include<cstdio>
using namespace std;
int a,a1,b,b1,gb,c,d;
int cd1,cd2,tc;
int ax;
char rw='@';
string mapp1[6][25]={{" |"," |"," |"," |"," |"," |"," |"," |"," |"," |"," |"," |"," ----- -- -- - ----- |"," - |","---- -- |"," |"," |"," |","----^--= |"," ---= |"," |"," |- |", " $ |"," ----|","^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",},{" |"," |"," |"," |"," |"," |"," |"," |"," |"," ==^ |"," - --^ |"," |"," |"," |"," |"," |"," ==^ |"," --- < |"," < |"," --- |", " -- <^ ^|"," -- < ||","--^ ---- - ^ $|", " ----= >--|","^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",},{" |"," |"," |"," |"," |"," |"," |"," |"," |"," ==- |"," ^===^ > < - |"," < > > < |"," > < |"," < |"," |"," ----- |"," == |"," ^|"," -=-=-==---- ^ $|"," <--|"," |", " === |"," > < |", "-== ^---^ == |", "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", },{" |"," |"," |"," ------ --- |"," - --- -- ^ |"," <---> |"," <-> -- <^ |"," -- <$|"," =^ <-> <|"," = ---^ |"," ^ |"," | |"," <|= |"," < |"," > |"," > ---^<^--^- |","= -- -- - -- --- -- - --- --- - |"," -- |"," |"," |"," |"," ^ ^ |"," <> < > > |","----^--^-^----^^^---^^-^^^--= --- -- ---^---=|","^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",},{"|> <|","|> <|","|> <|","|> ^ ^ <|",//21 0"|> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- <|","|> <|","|> ^^^^^ <|","|> ^ <|","|> - - - - - - <- - - <|","|> ^ <|","|> ^^^^^^ < ^^^^^^^ <|","|> ||","|> | | | | | ||","|> | |^^^^^^^^^^^^^^^^^^ ^ | ||","|> ||","|> ^^^^^^^^ ^ ^^^^^^^^^^^^<|","|> ^ ^ ^ <-> ^ <<|","|> <> <> ^ <|","|> ^ ^ ^ < ^^^^^^^ ||","||^^^^^^^^^^^^^^^^^^^^^> |^ ^ ||","|| ^ ^ <| - |> ||","|| > <| $ |> ||", "|| =-= ^ ||","|| ||","^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",},{" |"," $|"," -----|","--- --- = |"," |"," = ^^ = |"," <> |"," |"," ^^ |"," <> = |"," = |"," = ^^ |"," <> |"," - ^^ |"," ^^ <> = |"," <> ---= |"," ^^ |"," = <> |"," |"," < --= |"," ^^ |"," <>= |", " |","--= |","^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",}};
void sb_ycksbj();void sb_yd(int x,int y);void sb_yc();void g1();void g2();void gq_ys(int x);void gq_ys(int x)
{SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x); //x代表的是第几号颜色 前面的GetStdHandle(STD_OUTPUT_HANDLE)是获取当前窗口权柄,简单来说就是让这个颜色加在这个页面return;
}
void sb_ycksbj()
{HANDLE hStdin=GetStdHandle(STD_INPUT_HANDLE);DWORD mode;GetConsoleMode(hStdin,&mode);mode&=~ENABLE_QUICK_EDIT_MODE; //移除快速编辑模式mode&=~ENABLE_INSERT_MODE; //移除插入模式mode&=~ENABLE_MOUSE_INPUT;SetConsoleMode(hStdin, mode);
}
void sb_yd(int x,int y) //光标移动到x,y
{HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE);COORD pos;pos.X=x;pos.Y=y;SetConsoleCursorPosition(handle,pos);
}
void sb_yc()
{HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE);CONSOLE_CURSOR_INFO CursorInfo;GetConsoleCursorInfo(handle,&CursorInfo);//获取控制台光标信息CursorInfo.bVisible=false; //隐藏控制台光标SetConsoleCursorInfo(handle,&CursorInfo);//设置控制台光标状态
}
void gq_sx(int x,int y,char z,int l,bool pd)
{if(pd)//判断pd是否为真,可以写成if(pd==1) {system("cls");cout<<"刷新中...";sb_ycksbj();sb_yc();system("title 跑酷游戏");system("mode con cols=50 lines=25");sb_yd(0,0);system("cls");for(int i=0;i<24;i++){cout<<mapp1[l][i]<<endl;}cout<<mapp1[l][24];sb_yd(x,y);cout<<z;}else{system("cls");cout<<"刷新中...";sb_ycksbj();sb_yc();system("title 跑酷游戏");system("mode con cols=50 lines=25");system("cls");}return;
}
void gq_yx(int x,int y,char z,int l)
{int x1=x,yy1=y,ax;sb_yd(x1,yy1);cout<<z;for(;;){if(kbhit()!=0){ax=getch();if(ax==224){ax=getch();if(ax==72){for(int j=1;j<=4;j++){_sleep(100);if(yy1!=0&&mapp1[l][yy1-1][x1]==' '||mapp1[l][yy1-1][x1]=='$'&&mapp1[l][yy1-1][x1]!='|'){sb_yd(x1,yy1);cout<<" ";yy1--;sb_yd(x1,yy1);cout<<z;if(kbhit()!=0){ax=getch();if(ax==224){ax=getch();if(ax==75){if(x1!=0&&mapp1[l][yy1][x1-1]==' '||mapp1[l][yy1][x1-1]=='$'&&mapp1[l][yy1][x1-1]!='|'){x1--;sb_yd(x1,yy1);cout<<z<<" ";}}if(ax==77){if(x1!=49&&mapp1[l][yy1][x1+1]==' '||mapp1[l][yy1][x1+1]=='$'&&mapp1[l][yy1][x1+1]!='|'){sb_yd(x1,yy1);cout<<" "<<z;x1++;}}}if(ax==122||ax==90){system("cls");gq_sx(x1,yy1,z,l,1);}} }}}if(ax==75){if(x1!=0&&mapp1[l][yy1][x1-1]==' '||mapp1[l][yy1][x1-1]=='$'&&mapp1[l][yy1][x1-1]!='|'){x1--;sb_yd(x1,yy1);cout<<z<<" ";}}if(ax==77){if(x1!=49&&mapp1[l][yy1][x1+1]==' '||mapp1[l][yy1][x1+1]=='$'&&mapp1[l][yy1][x1+1]!='|'){sb_yd(x1,yy1);cout<<" "<<z;x1++;}}}if(ax==122||ax==90){system("cls");gq_sx(x1,yy1,z,l,1);}}while(mapp1[l][yy1+1][x1]==' '||mapp1[l][yy1+1][x1]=='$'){_sleep(100);sb_yd(x1,yy1);cout<<" ";yy1+=1;sb_yd(x1,yy1);cout<<z;if(kbhit()!=0){ax=getch();if(ax==224){ax=getch();if(ax==75){if(x1!=0&&mapp1[l][yy1][x1-1]==' '||mapp1[l][yy1][x1-1]=='$'&&mapp1[l][yy1][x1-1]!='|'){x1--;sb_yd(x1,yy1);cout<<z<<" ";}}if(ax==77){if(x1!=49&&mapp1[l][yy1][x1+1]==' '||mapp1[l][yy1][x1+1]=='$'&&mapp1[l][yy1][x1+1]!='|'){sb_yd(x1,yy1);cout<<" "<<z;x1++;}}}if(ax==122||ax==90){system("cls");gq_sx(x1,yy1,z,l,1);}}if(mapp1[l][yy1+1][x1]=='^'||mapp1[l][yy1][x1+1]=='<'||mapp1[l][yy1][x1-1]=='>'){sb_yd(x1,yy1);cout<<" ";x1=x;yy1=y;sb_yd(x1,yy1);cout<<z;} } if(mapp1[l][yy1+1][x1]=='='){int jc=1;for(int j=1;j<=8;j++){if(mapp1[l][yy1-1][x1]==' '){_sleep(10);sb_yd(x1,yy1);cout<<" ";yy1--;sb_yd(x1,yy1);cout<<z;if(kbhit()!=0){ax=getch();if(ax==224){ax=getch();if(ax==75){if(x1!=0&&mapp1[l][yy1][x1-1]==' '||mapp1[l][yy1][x1-1]=='$'&&mapp1[l][yy1][x1-1]!='|'){x1--;sb_yd(x1,yy1);cout<<z<<" ";}}if(ax==77){if(x1!=49&&mapp1[l][yy1][x1+1]==' '||mapp1[l][yy1][x1+1]=='$'&&mapp1[l][yy1][x1+1]!='|'){sb_yd(x1,yy1);cout<<" "<<z;x1++;}}}if(ax==122||ax==90){system("cls");gq_sx(x1,yy1,z,l,1);}} }if(mapp1[l][yy1+1][x1]=='^'||mapp1[l][yy1][x1+1]=='<'||mapp1[l][yy1][x1-1]=='>'){sb_yd(x1,yy1);cout<<" ";x1=x;yy1=y;sb_yd(x1,yy1);cout<<z;}} } if(mapp1[l][yy1+1][x1]=='^'||mapp1[l][yy1][x1+1]=='<'||mapp1[l][yy1][x1-1]=='>'){sb_yd(x1,yy1);cout<<" ";x1=x;yy1=y;sb_yd(x1,yy1);cout<<z;}if(mapp1[l][yy1][x1]=='$'){_sleep(10);system("cls");sb_yd(0,0);cout<<"你赢了!"<<endl;cout<<"按空格返回。";if(getch()==' '){system("cls");sb_yd(0,0);return;}}}
}
void g1()
{cout<<endl<<endl;cout<<"\n\n\n\n\n\n\n\n\n 第一关:新手教程。";cout<<endl<<endl;_sleep(500);system("cls");for(int i=0;i<24;i++){cout<<mapp1[0][i]<<endl;}cout<<mapp1[0][24];gq_yx(0,17,rw,0);return;
}
void g2()
{cout<<endl<<endl;cout<<"\n\n\n\n\n\n\n\n\n 第二关:蹦床世界。"<<endl; cout<<endl<<endl;_sleep(500);system("cls");for(int i=0;i<24;i++){cout<<mapp1[1][i]<<endl;}cout<<mapp1[1][24];gq_yx(0,21,rw,1);return;
}
void g3()
{cout<<endl<<endl;cout<<"\n\n\n\n\n\n\n\n\n 第三关:明枪易躲,暗箭难防(1)。"<<endl; cout<<endl<<endl;_sleep(500);system("cls");for(int i=0;i<24;i++){cout<<mapp1[2][i]<<endl;}cout<<mapp1[2][24];gq_yx(0,22,rw,2);return;
}
void g4()
{cout<<endl<<endl;cout<<"\n\n\n\n\n\n\n\n\n 第四关:明枪易躲,暗箭难防(2)。"<<endl; cout<<endl<<endl;_sleep(500);system("cls");for(int i=0;i<24;i++){cout<<mapp1[3][i]<<endl;}cout<<mapp1[3][24];gq_yx(0,22,rw,3);return;
}
void g5()
{cout<<endl<<endl;cout<<"\n\n\n\n\n\n\n\n\n 第五关:心跳刺方。";cout<<endl<<endl;_sleep(500);system("cls");for(int i=0;i<24;i++){cout<<mapp1[4][i]<<endl;}cout<<mapp1[4][24];gq_yx(23,0,rw,4);return;
}
void g6()
{cout<<endl<<endl;cout<<"\n\n\n\n\n\n\n\n\n 第六关:飞得更高。";cout<<endl<<endl;_sleep(500);system("cls");for(int i=0;i<24;i++){cout<<mapp1[5][i]<<endl;}cout<<mapp1[5][24];gq_yx(0,22,rw,5);return;
}
int hy()
{if(c==0){cout<<"\n\n\n\n\n\n\n\n\n\n\n\n ============欢迎============ "<<endl;c++;_sleep(1000);system("cls");}cout<<"\n\n\n\n\n\n\n 首页\n\n\n\n\n";cout<<" 1.开始游戏\n\n\n\n";cout<<" 2.退出";a=0;a=getch()-'0';return a;
}
void gq()
{ for(;;) {cout<<"\n\n\n\n\n\n 关卡\n\n\n"<<endl;cout<<" 1.新手教程 2.蹦床世界\n\n"<<endl; cout<<" 3.明枪易躲,暗箭难防(1)\n\n"<<endl;cout<<" 4.明枪易躲,暗箭难防(2)\n\n"<<endl;cout<<" 5.心跳刺方 6.飞得更高\n\n"<<endl;cout<<" 7.退出 "<<endl;a=0;a=getch()-'0';switch(a){case 1 :{system("cls");g1(); break; }case 2 :{system("cls");g2(); break; }case 3 :{system("cls");g3();break;}case 4 :{system("cls");g4();break;}case 5 :{system("cls");g5();break; }case 6 :{system("cls");g6();break; }case 7 :{system("cls");tc=1;break;}case 74 :case 42 :{gq_sx(0,0,0,0,0);break;}default:{system("cls");cout<<"\n\n\n\n\n\n\n\n\n\n\n\n 请输入正确的字符!!!";_sleep(175);system("cls");a=0;continue;}}if(tc==1){tc=0;break;}}system("cls");return ;
}
int main()
{cout<<"加载中...";sb_ycksbj();sb_yc();system("title 跑酷游戏");system("mode con cols=50 lines=25");system("cls");for(;;){hy();switch(a) {case 1 :{system("cls");gq(); break;}case 2 :{system("cls");cout<<endl<<endl<<" 再见! "<<endl<<endl;_sleep(750);system("cls");exit(0);break;}case 74 :case 42 :{gq_sx(0,0,0,0,0);break;}default:{system("cls");cout<<"\n\n\n\n\n\n\n\n\n\n\n\n 请输入正确的字符!!!";_sleep(175);a=0;system("cls");break;}}}
}
这篇关于devc++跑酷游戏2.4.0的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!