hello大家好,我是阳了个阳C++,最近某游戏的恶魔轮盘赌非常出名,所以我也用C++复刻了一个。话不多说,请看代码:
这一版是无道具版(因为道具太难写了……)
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
string name;
int t,f,life,th;
bool check[21];
void cls(){
system("cls");
}
void startgame(){
system("color 4");
cout<<"欢迎来到恶魔轮盘赌\n\n";
Sleep(2000);
cout<<"我是你的对手,StarSword\n\n";
Sleep(2000);
cout<<"请输入你的名字\n";
cin>>name;
cls();
}
void choose(){
cout<<name<<",请选择每轮真弹数量,假弹数量,以及电量格数\n";
Sleep(2000);
cin>>t>>f>>life;
cls();
}
void reload(){
int T=t,F=f;
for(int i=1;i<=t+f;i++){
int tmp=rand()%2;
if(tmp==1){
if(T){
T--;
check[i]=1;
continue;
}
}
F--;
check[i]=0;
}
}
int main(){
srand(time(NULL));
char ok='y';
startgame();
while(ok=='y'){
choose();
reload();
int i=1;
int lifea=life,lifeb=life;
bool gun=1;
while(1){
if(i==t+f+1){
cout<<"正在重新装弹中\n\n";
Sleep(2000);
reload();
i=1;
cls();
}
if(gun){
cout<<name<<",你要向对方开枪吗(y/n)\n";
char bomb;
cin>>bomb;
if(bomb=='y'){
if(check[i]){
cout<<"砰!这枚是真弹\n\n";
lifeb--;
}else{
cout<<"咔!这枚是假弹\n\n";
}
}else{
if(check[i]){
cout<<"砰!这枚是真弹\n\n";
lifea--;
}else{
cout<<"咔!这枚是假弹\n\n";
}
}
Sleep(2000);
if(lifea==0){
cls();
cout<<"很遗憾,你输了\n\n";
return 0;
}
if(lifeb==0){
cls();
cout<<"恭喜你,你赢了!\n\n";
break;
}
cout<<"你还剩"<<lifea<<"格电量,对方还剩"<<lifeb<<"格电量\n\n";
if(bomb=='n'&&!check[i]){
gun=1;
}else{
gun=0;
}
Sleep(2000);
cls();
}else{
cls();
Sleep(2000);
cout<<"对方正在准备中\n\n";
Sleep(2000);
if(check[i]){
cout<<"对方击中了你\n\n";
lifea--;
Sleep(2000);
if(lifea==0){
cout<<"很遗憾,你输了!\n\n";
Sleep(1000);
return 0;
}
cout<<"你还剩"<<lifea<<"格电量,对方还剩"<<lifeb<<"格电量\n\n";
}else{
cout<<"对方没有击中你\n\n";
Sleep(2000);
cout<<"你还剩"<<lifea<<"格电量,对方还剩"<<lifeb<<"格电量\n\n";
}
gun=1;
Sleep(2000);
cls();
}
i++;
}
Sleep(2000);
cls();
cout<<"如果你还想继续,请按y\n";
cin>>ok;
}
return 0;
}
如果有大佬发现BUG的话,欢迎向我提出
请大家多多点赞,道具版恶魔轮盘赌很快就好!!!