本文主要是介绍【c++游戏】噩梦轮盘赌(俄罗斯转盘),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
源代码
#include<bits/stdc++.h>
#include<time.h>
#include<windows.h>
using namespace std;
//
int hp=3;
int emhp=3;
//
int b;
int dantang[6];
int emhh;
int shidan=0;
int kondan=0;
int zdzt=0;int how;
bool awa(){srand(time(NULL));if (shidan==0){return false;}else if(kondan==0&&shidan>0){return true;}else if(rand()%(shidan+kondan)/shidan==0&&shidan>=1){return true;}else{return false;}
}
void say(string str){for (int i=0;i<str.size();i++){cout<<str[i];Sleep(1); }cout<<"\n";Sleep(500);
}
void chushihua(){srand(time(NULL));how=rand()%10+3;srand(time(NULL));shidan=rand()%how/2+2;kondan=how-shidan;say("初始化完成");cout<<",共"<<shidan<<"发实弹,"<<kondan<<"发空弹\n\n";
}int main(){system("title 恶魔轮盘赌");say("恶魔轮盘赌"); system("pause"); say("你是一个SuperBoy");say("你为了钱和一个恶魔玩俄罗斯转盘");say("赢了可以获得500w刀乐");while(1){a2:system("cls");if(hp<=0){system("color 4");say("You die...");break;}if(emhp<=0){say("You win...");say("\n你获得了500w"); break;}if(shidan<=0&&kondan<=0){chushihua();say("新的一轮...\n");Sleep(2000);}cout<<"我方血量:"<<hp<<"\n恶魔血量:"<<emhp<<"\n";cout<<"\n\n现在"<<shidan<<"发实弹,"<<kondan<<"发空弹\n\n";say("现在做出你的选择");say("按1朝自己开枪");say("按2朝恶魔开枪\n\n>>>");cin>>b;switch(b){case 1:{srand(time(NULL)); if(awa()){say("你正在上膛");say("上膛完成");say("3");say("2");say("1");cout<<"砰的一声......"<<endl;cout<<"你扣了一滴血";Sleep(1000);shidan--;hp--;}else{say("你正在上膛"); say("上膛完成");say("3");say("2");say("1");say("是空弹");Sleep(1000);kondan--; goto a2;}break;}case 2:{if(awa()){say("你正在上膛");say("上膛完成");say("3");say("2");say("1");cout<<"砰的一声..."<<endl;cout<<"恶魔扣了一滴血";Sleep(1000);shidan--;emhp--;Sleep(500);}else{say("你正在上膛");say("上膛完成");say("3");say("2");say("1");say("是空弹");Sleep(1000);kondan--;Sleep(500);} break;}} if(shidan<=0&&kondan<=0){chushihua();say("新的一轮...\n");goto a2;Sleep(2000);}if(hp<=0){system("color 4");say("You die...");break;}if(emhp<=0){say("You win...");say("\n你获得了500w"); break;}a1: system("cls");cout<<"\n\n\n现在是恶魔的回合\n";cout<<"\n\n现在"<<shidan<<"发实弹,"<<kondan<<"发空弹\n\n"; srand(time(NULL));emhh=rand()%2;if(emhh==1||kondan==0||kondan<shidan){say("\n恶魔将枪对准了你\n");if(awa()){say("恶魔正在上膛");say("上膛完成");say("3");say("2");say("1");cout<<"砰的一声"<<endl;cout<<"你扣了一滴血";Sleep(1000);shidan--;hp--;} else {say("恶魔正在上膛");say("上膛完成");say("3");say("2");say("1");say("是空弹");Sleep(1000);kondan-=1;}}else{say("\n恶魔将枪对准了自己\n");if(awa()){say("恶魔正在上膛");say("上膛完成");say("3");say("2");say("1");cout<<"砰的一声"<<endl;cout<<"恶魔扣了一滴血";Sleep(1000);shidan--;emhp--;} else {say("恶魔正在上膛");say("上膛完成");say("3");say("2");say("1");say("是空弹");Sleep(1000);kondan--;goto a1;}}Sleep(1000);system("cls"); }}
Tip
本游戏为同学原创,禁止抄袭!!!
这篇关于【c++游戏】噩梦轮盘赌(俄罗斯转盘)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!