自编超爽的对战游戏 非常有趣
作者:互联网
嗯,其实我之前是以资源的方式向大家展示,但系统自动调价(C币)太高,我不忍心让大家花那么多C币下载,就把游戏代码放到文章上让大家复制。我只有一个愿望,送我那个免费的赞。
#include <iostream>
#include<bits/stdc++.h>
#include <stdlib.h>
#include<conio.h>
#include<windows.h>
using namespace std;
//主角
double zhujueshengming=100;
int zhujuegongjili=20;
int zhujuefangyuli=10;
int money=0;
//对手
int shengming=5000;
int gongjili=1000;
int fangyuli=500;
int jiuzhu=5;
void welcome();
void yaodian();
void zhuangtai();
void zhuanqian();
void zhuangbeidian();
void zhandou();
void jinbijiuzhu();
string name;
int mony=600,jb=5,r=0,wait1=400,wait2=500;
double xn=20,dx,zx,xx,sx=20,fy=1,gj=4,m=1212123,mm=321531;
bool f=0,sl=1;
int main()
{
welcome();
Sleep(500);
while(1)
{
cout<<"你要和别人格斗,现在在准备。"<<endl;
cout<<"1.赚钱"<<endl;
cout<<"2.自己的状态"<<endl;
cout<<"3.装备店"<<endl;
cout<<"4.药店"<<endl;
cout<<"5.金币(钱)救助,还剩"<<jiuzhu<<"次"<<endl;
cout<<"6.开始战斗!"<<endl;
int zhunbei;
cin>>zhunbei;
switch(zhunbei)
{
case 1 : zhuanqian();break;
case 2 : zhuangtai();break;
case 3 : zhuangbeidian();break;
case 4 : yaodian();break;
case 5 : jinbijiuzhu();break;
case 6 : zhandou();break;
default : cout<<"请不要乱选!"<<endl;break;
}
}
}
void welcome()
{
system("cls");
cout<<"对战游戏!"<<endl;
cout<<"作者:dinosaursmallmi"<<endl;
Sleep(2000);
system("cls");
}
void zhuangtai()
{
cout<<"你:"<<endl;
cout<<"生命:"<<zhujueshengming<<endl;
cout<<"攻击力:"<<zhujuegongjili<<endl;
cout<<"防御力:"<<zhujuefangyuli<<endl;
cout<<"钱:"<<money<<endl;
cout<<endl;
cout<<"对方:"<<endl;
cout<<"生命:"<<shengming<<endl;
cout<<"攻击力:"<<gongjili<<endl;
cout<<"防御力:"<<fangyuli<<endl;
system("pause");
system("cls");
}
void zhuanqian()
{
long long qs=time(0);
cout<<"正在挖矿(赚钱)中...\n按任意键结束\n";
while(1){
if(kbhit()){
break;
}else{
if(time(0)-qs>250){
cout<<"你已经筋疲力尽了.."<<endl;
getch();
break;
}
}
}
long long zz=time(0)-qs,hd=0;
if(zz>=3){
hd=zz/3*2;
money+=hd;
}
cout<<"你挖(赚)到了"<<hd<<"元"<<endl;Sleep(1000);
getch();
system("cls");
}
void jinbijiuzhu()
{
cout<<"确定救助?(还剩"<<jiuzhu<<"次)(y/n)"<<endl;
char U;
cin>>U;
while(U!=('n'||'N'))
{
if(jiuzhu!=0)
{
jiuzhu-=1;
cout<<"成功救助"<<endl;
money+=1000;
system("pause");
cout<<"还要救助吗?按1显示自己的状态,按2补助,按3退出"<<endl;
int T;
cin>>T;
switch(T)
{
case 1 : {
cout<<"你:"<<endl;
cout<<"生命:"<<zhujueshengming<<endl;
cout<<"攻击力:"<<zhujuegongjili<<endl;
cout<<"防御力:"<<zhujuefangyuli<<endl;
cout<<"钱:"<<money<<endl;
cout<<"剩余救助次数:"<<jiuzhu<<endl;
cout<<endl;
cout<<"对方:"<<endl;
cout<<"生命:"<<shengming<<endl;
cout<<"攻击力:"<<gongjili<<endl;
cout<<"防御力:"<<fangyuli<<endl;
system("pause");
cout<<"要补助吗(y/n)"<<endl;
char S;
cin>>S;
if((S=='y'||'Y')&&(jiuzhu>0))
{
jiuzhu-=1;
cout<<"成功救助"<<endl;
money+=1000;
system("pause");
break;
}
else
{
cout<<"再见"<<endl;
system("pause");
break;
}
}
case 2 : if(jiuzhu>0)
{
jiuzhu-=1;
cout<<"成功救助"<<endl;
money+=1000;
system("pause");
break;
}
else
{
cout<<"次数不够"<<endl;
system("pause");
break;
}
case 3 : {
cout<<"再见"<<endl;
system("pause");
break;
}
}
break;
}
else
{
cout<<"次数不够"<<endl;
system("pause");
break;
}
}
}
void zhuangbeidian()
{
cout<<"欢迎,请问你要买什么"<<endl;
cout<<"1.短剑20元"<<endl;
cout<<"2.长刀50元"<<endl;
cout<<"3.铁剑150元"<<endl;
cout<<"4.金剑500元"<<endl;
cout<<"5.钻石剑2000元"<<endl;
cout<<"6.离开"<<endl;
int zhuangbeidiana;
cin>>zhuangbeidiana;
while(zhuangbeidiana!=6)
{
switch(zhuangbeidiana)
{
case 1 :{ if(money>20)
{
cout<<"购买成功!"<<endl;
system("pause");
money-=20;
zhujuegongjili=zhujuegongjili+10;
zhujuefangyuli+=5;
break;
}
else
{
cout<<"钱不够"<<endl;
}
}
case 2 :{ if(money>50)
{
cout<<"购买成功!"<<endl;
system("pause");
money-=50;
zhujuegongjili=zhujuegongjili+25;
zhujuefangyuli+=12;
break;
}
else
{
cout<<"钱不够"<<endl;
system("pause");
}
}
case 3 : {if(money>150)
{
cout<<"购买成功!"<<endl;
system("pause");
money-=150;
zhujuegongjili=zhujuegongjili+75;
zhujuefangyuli+=35;
break;
}
else
{
cout<<"钱不够"<<endl;
system("pause");
}
}
case 4 :{ if(money>500)
{
cout<<"购买成功!"<<endl;
system("pause");
money-=500;
zhujuegongjili=zhujuegongjili+250;
zhujuefangyuli+=125;
break;
}
else
{
cout<<"钱不够"<<endl;
system("pause");
}
}
case 5 :{ if(money>2000)
{
cout<<"购买成功!"<<endl;
system("pause");
money-=2000;
zhujuegongjili=zhujuegongjili+1000;
zhujuefangyuli+=500;
break;
}
else
{
cout<<"钱不够"<<endl;
system("pause");
}
}
case 6 : break;
default : cout<<"请不要乱选!"<<endl;break;
}
break;
}
system("cls");
}
void yaodian()
{
cout<<"欢迎,请问你要买什么"<<endl;
cout<<"1.水5元"<<endl;
cout<<"2.绷带20元"<<endl;
cout<<"3.急救包50元"<<endl;
cout<<"4.能量饮料200元"<<endl;
cout<<"5.止痛药500元"<<endl;
cout<<"6.离开"<<endl;
int yaodiana;
cin>>yaodiana;
while(yaodiana!=6)
{
switch(yaodiana)
{
case 1 :{ if(money>5)
{
cout<<"购买成功!"<<endl;
system("pause");
money-=5;
zhujueshengming+=10;
break;
}
else
{
cout<<"钱不够"<<endl;
system("pause");
break;
}
}
case 2 :{ if(money>20)
{
cout<<"购买成功!"<<endl;
system("pause");
money-=20;
zhujueshengming+=40;
break;
}
else
{
cout<<"钱不够"<<endl;
system("pause");
break;
}
}
case 3 : {if(money>50)
{
cout<<"购买成功!"<<endl;
system("pause");
money-=50;
zhujueshengming+=100;
break;
}
else
{
cout<<"钱不够"<<endl;
system("pause");
break;
}
}
case 4 : {if(money>200)
{
cout<<"购买成功!"<<endl;
system("pause");
money-=200;
zhujueshengming+=400;
break;
}
else
{
cout<<"钱不够"<<endl;
system("pause");
break;
}
}
case 5 :{ if(money>500)
{
cout<<"购买成功!"<<endl;
system("pause");
money-=500;
zhujueshengming+=1000;
break;
}
else
{
cout<<"钱不够"<<endl;
system("pause");
break;
}
}
case 6 : break;
default : cout<<"请不要乱选!"<<endl;break;
}
break;
}
system("cls");
}
void zhandou()
{
int D,E;
//对手 shengming=5000; gongjili=1000; fangyuli=500; zhujueshengming=100; zhujuegongjili=20; money=0; zhujuefangyuli=10;
cout<<"要战斗按y,逃跑按n"<<endl;
char Z;
cin>>Z;
while(Z!=('n'||'N'))
{
cout<<"你打掉了对方"<<zhujuegongjili-fangyuli<<"滴血,对方打掉你"<<gongjili-zhujuefangyuli<<endl;
D=zhujuegongjili-fangyuli;
E=gongjili-zhujuefangyuli;
shengming-= D;
zhujueshengming-=E;
cout<<"对方还剩"<<shengming<<"滴血,你还剩"<<zhujueshengming<<"滴血"<<endl;
system("pause");
if(zhujueshengming<0)
{
cout<<"你被打死了"<<endl;
Sleep(3000);
system("pause");
cout<<"50元复活,要吗(y/n)"<<endl;
char Y;
cin>>Y;
if(Y=='y'||'Y')
{
if(money>50)
{
money-=50;
cout<<"成功复活至小镇"<<endl;
system("pause");
break;
shengming+=100;
gongjili+=200;
fangyuli+=500;
zhujueshengming=20;
}
else
{
cout<<"钱不够,你还是死"<<endl;
Sleep(2000);
cout<<"再见"<<endl;
system("pause");
exit(0);
}
}
cout<<"再见"<<endl;
system("pause");
exit(0);
}
if(shengming<0)
{
cout<<"对方被打死了,你真厉害!"<<endl;
Sleep(3000);
system("pause");
cout<<"还要继续吗(回到小镇,继续准备,因为对方更强)(y/n)"<<endl;
char X;
cin>>X;
if(X=='y'||'Y')
{
cout<<"回到小镇"<<endl;
system("pause");
system("cls");
break;
//对手 shengming=5000; gongjili=1000; fangyuli=500; zhujueshengming=100; zhujuegongjili=20; money=0; zhujuefangyuli=10;
shengming+=100;
gongjili+=200;
fangyuli+=500;
}
else
{
cout<<"再见"<<endl;
system("pause");
exit(0);
}
}
}
}
嗯~ o(* ̄▽ ̄*)o
记得送个赞(·u·)
标签:case,break,cout,int,money,自编,超爽,对战,void 来源: https://blog.csdn.net/gbrehgbrhgbjkakl/article/details/122437995