Dev-c++的小游戏代码(可直接复制)

今天我给大家一点实用的小游戏,希望支持。
直接上代码:

#include<bits/stdc++.h>
#include<windows.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>
#include <cstring>
#include <cstdio>
#include <iostream>
#define  N 22
using namespace std;
const int MAXN=15;
const int MAX=25;
int main(void){
   
long long xiaoguai=500,daguai=2000,xiaoguaixue=500,daguaixue=2000,dasi=0,xiaosi=0,touzi=0,xiaofei=0;
int r1=0,r2=0,r3=0,r4=0,r5=0,r6=0,r7=0; 
long long shai=0,shaici=0; 
int o[MAXN]={
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},q[MAXN]={
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int r[MAXN]={
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},s[MAXN]={
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
long long a=1,aa,b,c,d,e,ee=0,f,ff,g,gg=10,h,i,j,k=0,l,m,n,nn=1,p,t,u,v,vv,w,x,y,z,zz=0;
int bb[MAX]={
   0,0,0,0,0,3,0,0,0,3,0,4,0,3,0,5,4,0,0,4,0,3,0,5,0};
int cc[MAX]={
   1,1,1,1,2,1,1,2,2,1,1,1,2,1,1,1,1,1,1,1,2,1,2,1,1};
char input,put,in;
long long hong=0,lu=0,mu=0,shi=0,xuyuan=0,chanzi=0,diban=10,qiangbi=10,chuang=10,zhuo=10,num;
long long jingxiaolibao=0,jingdalibao=0,wuxiaolibao=0,wudalibao=0,tixiaolibao=0,tidalibao=0,xuexiaolibao=0,xuedalibao=0;
int mao=0,gou=0,niu=0,ma=0,yang=0,maoji=1,gouji=1,niuji=1,maji=1,yangji=1,maomi=0,goumi=0,niumi=0,mami=0,yangmi=0;
long long gongjili=10,xueliang=100,jingbi=100,tili=100,jingyan=0,shengjixian=50,xiaogong=10,dagong=50,dengji=1;
long long suliao=0,muzhi=0,tiezhi=0,shuiguo=0,cai=0,fangshui=0;
long long suci=0,muci=0,tieci=0,shuici=0,caici=0;
string hh;
cout<<"加载中..."<<endl;
cout<<"提示:离小怪或大怪太近会被乎死";
Sleep(1000);
system("cls");
cout<<"加载中..."<<endl;
cout<<"提示:大怪会施法";
Sleep(1000); 
system("cls");
cout<<"加载中..."<<endl;
cout<<"提示:不买氧气罐会在冒险的时候淹死";
Sleep(1000);
system("cls");
cout<<"加载中..."<<endl;
cout<<"提示:挖泥土前要买铲子";
Sleep(1000);
system("cls");
cout<<"加载中..."<<endl;
cout<<"提示:投资可能会亏钱";
Sleep(1000); 
system("cls");
cout<<"加载中..."<<endl;
cout<<"提示:冒险里的草丛里会有小偷和狼";
Sleep(1000);
system("cls");
cout<<"加载中..."<<endl;
cout<<"提示:宠物在打怪时很有帮助";
Sleep(1000);
system("cls");
cout<<"加载中..."<<endl;
cout<<"提示:升级宠物可以提升耐久度";
Sleep(1000);
system("cls");
cout<<"输入用户名:";
cin>>hh; 
if(hh=="爷是攻"){
   
jingbi=1000000; 
xueliang=1000000;
tili=1000000;
}
system("cls");
while(1){
   
while(1){
   
Sleep(100); 
system("cls");
cout<<"[按a向左][按d向右][我=+][按e进入此屋]"<<endl;
cout<<"/ ̄ ̄\\/ ̄ ̄\\/ ̄ ̄\\/ ̄ ̄\\/ ̄ ̄\\/ ̄ ̄\\/ ̄ ̄\\/ ̄ ̄\\/ ̄ ̄\\/ ̄ ̄\\/    \\"<<endl;
cout<<"|小怪||大怪||购物||投资||冒险||交易||许愿||任务|| 摇 ||我的||专业|"<<endl;
cout<<"|森林||森林|| 街 ||    ||    || 铺 || 池 || 栏 ||骰子||家园||打铁|"<<endl;
cout<<"|^ __||^ __||^ __||^ __||^ __||^ __||^ __||^ __||^ __||^ __||^ __|"<<endl;
cout<<"| |   | |   | |   | |   | |   | |   | |   | |   | |   | |   | |   "<<endl;
for(p=1;p<=a;p++)
cout<<" ";
cout<<"+";
if(kbhit()) {
   
put=getch();  
if(put=='a')   
a=a-6; 
if(put=='d')
a=a+6;   
if(put=='e'){
   
if(a==1||a==7||a==13||a==19||a==25||a==31||a==37||a==43||a==49||a==55||a==61||a==67)
break;
else{
   
cout<<"这里不是入口";
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
}
}
}
if(a==61){
   
cout<<"更多功能,敬请期待"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
if(a==55){
   
system("cls");
cout<<"1,我的小屋"<<endl;
cout<<"2,我的礼包"<<endl;
cout<<"3,我的状态"<<endl;
cout<<"4,我的宠物"<<endl;
cout<<"5,我的背包"<<endl;
cout<<"6,我的武器"<<endl;
cout<<"7,返回"<<endl;
cin>>t;
if(t==6){
   
while(1){
   
system("cls");
if(suliao==0&&muzhi==0&&tiezhi==0&&shuiguo==0&&cai==0){
   
cout<<"你暂无任何武器"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
break;
}
else{
   
if(suliao>=1){
   
cout<<"塑料餐具刀"<<suliao<<"把"<<endl;
cout<<"增加5点攻击力"<<endl;
cout<<"选择武器按1"<<endl;
} 
if(muzhi>=1){
   
cout<<"木质餐具刀"<<muzhi<<"把"<<endl;
cout<<"增加20点攻击力"<<endl;
cout<<"选择武器按2"<<endl;
} 
if(tiezhi>=1){
   
cout<<"铁制餐具刀"<<tiezhi<<"把"<<endl;
cout<<"增加50点攻击力"<<endl;
cout<<"选择武器按3"<<endl;
} 
if(shuiguo>=1){
   
cout<<"水果刀"<<shuiguo<<"把"<<endl;
cout<<"增加100点攻击力"<<endl;
cout<<"选择武器按4"<<endl;
} 
if(cai>=1){
   
cout<<"菜刀"<<cai<<"把"<<endl;
cout<<"增加500点攻击力"<<endl;
cout<<"选择武器按5"<<endl;
} 
cout<<"返回按6"<<endl; 
cin>>aa;
if(aa==1){
   
gongjili=gongjili+5; 
suci=suci+1; 
suliao=suliao-1;
cout<<"选择成功"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
if(aa==2){
   
gongjili=gongjili+20;
muci=muci+1;
muzhi=muzhi-1;
cout<<"选择成功"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
if(aa==3){
   
gongjili=gongjili+50;
tieci=tieci+1;
tiezhi=tiezhi-1;
cout<<"选择成功"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
if(aa==4){
   
gongjili=gongjili+100;
shuici=shuici+1;
shuiguo=shuiguo-1;
cout<<"选择成功"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
if(aa==5){
   
gongjili=gongjili+500;
caici=caici+1;
cai=cai-1; 
cout<<"选择成功"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
if(aa==6) 
break;
}
}
} 
if(t==5){
   
system("cls");
cout<<"你有"<<hong<<"块超稀有红宝石"<<endl;
cout<<"你有"<<lu<<"块稀有绿宝石"<<endl;
cout<<"你有"<<mu<<"块木头"<<endl;
cout<<"你有"<<shi<<"块石头"<<endl;
cout<<"你有"<<jingbi<<"枚金币"<<endl;
cout<<"你有"<<shai<<"枚骰子"<<endl;
cout<<"按任意键回到主界面"<<endl;
getch();
system("cls");
}
if(t==4){
   
system("cls");
if(mao==0&&gou==0&&niu==0&&ma==0&&yang==0){
   
cout<<"你暂无任何宠物"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
else{
   
if(mao==1){
   
cout<<"猫猫"<<maoji<<"级"<<endl;
cout<<"技能:每次被攻击后恢复"<<maoji*5<<"点血量"<<endl;
cout<<"升级需耗费"<<maoji*100<<"金币"<<endl;
cout<<"剩余使用次数:"<<50-maomi<<"次"<<endl;
cout<<"升级按1 选择宠物按5 卸下宠物按10"<<endl;
} 
if(gou==1){
   
cout<<"狗狗"<<gouji<<"级"<<endl;
cout<<"技能:每次被攻击后恢复"<<gouji*10<<"点血量"<<endl;
cout<<"升级需耗费"<<gouji*150<<"金币"<<endl;
cout<<"剩余使用次数:"<<50-goumi<<"次"<<endl;
cout<<"升级按2 选择宠物按6 卸下宠物按11"<<endl;
}
if(niu==1){
   
cout<<"牛牛"<<niuji<<"级"<<endl;
cout<<"技能:每次额外攻击大怪或小怪"<<niuji*10<<"点血量"<<endl;
cout<<"升级需耗费"<<niuji*250<<"金币"<<endl;
cout<<"剩余使用次数:"<<50-niumi<<"次"<<endl;
cout<<"升级按3 选择宠物按7 卸下宠物按12"<<endl;
}
if(yang==1){
   
cout<<"羊羊"<<endl;
cout<<"技能:使大怪或小怪对你的攻击减半"<<endl;
cout<<"剩余使用次数:"<<50-yangmi<<"次"<<endl;
cout<<"选择宠物按8 卸下宠物按13"<<endl;
}
if(ma==1){
   
cout<<"马马 "<<endl;
cout<<"技能:使大怪或小怪的血量瞬间减半"<<endl;
cout<<"剩余使用次数:"<<50-mami<<"次"<<endl;
cout<<"选择宠物按9 卸下宠物按14"<<endl; 
}
cin>>j;
if(j==1){
   
if(jingbi>=maoji*100){
   
cout<<"升级成功"<<endl;
jingbi=jingbi-maoji*100;
maoji=maoji+1;
maomi=maomi-10; 
}
else{
   
cout<<"金币不足"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
}
if(j==2){
   
if(jingbi>=gouji*150){
   
cout<<"升级成功"<<endl;
jingbi=jingbi-gouji*150;
gouji=gouji+1;
}
else{
   
cout<<"金币不足"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
}
if(j==3){
   
if(jingbi>=niuji*100){
   
cout<<"升级成功"<<endl;
jingbi=jingbi-niuji*250;
niuji=niuji+1;
niumi=niumi-10;
}
else{
   
cout<<"金币不足"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
}
if(j==5){
   
k=j;
cout<<"选择成功"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
if(j==6){
   
k=j;
cout<<"选择成功"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
if(j==7){
   
k=j;
cout<<"选择成功"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
if(j==8){
   
k=j;
cout<<"选择成功"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
if(j==9){
   
k=j;
cout<<"选择成功"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
if(j==10){
   
if(k==5){
   
cout<<"按任意键继续"<<endl;
k=0;
getch();
system("cls");
}
else{
   
cout<<"你暂未选择该宠物"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
}
if(j==11){
   
if(k==6){
   
cout<<"按任意键继续"<<endl;
k=0;
getch();
system("cls");
}
else{
   
cout<<"你暂未选择该宠物"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
}
if(j==12){
   
if(k==7){
   
cout<<"按任意键继续"<<endl;
k=0;
getch();
system("cls");
}
else{
   
cout<<"你暂未选择该宠物"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
}
if(j==13){
   
if(k==8){
   
cout<<"按任意键继续"<<endl;
k=0;
getch();
system("cls");
}
else{
   
cout<<"你暂未选择该宠物"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
}
if(j==14){
   
if(k==9){
   
cout<<"按任意键继续"<<endl;
k=0;
getch();
system("cls");
}
else{
   
cout<<"你暂未选择该宠物"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
}
}
} 
if(t==3){
   
system("cls");
cout<<"我的状态:"<<endl;
cout<<"等级:"<<dengji<<endl;
cout<<"经验:"<<jingyan<<"/"<<shengjixian<<endl;
cout<<"血量:"<<xueliang<<endl;
cout<<"体力:"<<tili<<endl;
cout<<"攻击力:"<<gongjili<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
if(t==2){
   
system("cls");
while(1){
   
system("cls");
cout<<"1,血量小礼包*"<<xuexiaolibao<<" 2,血量大礼包*"<<xuedalibao<<endl;
cout<<"3,武器小礼包*"<<wuxiaolibao<<" 4,武器大礼包*"<<wudalibao<<endl;
cout<<"5,体力小礼包*"<<tixiaolibao<<" 6,体力大礼包*"<<tidalibao<<endl;
cout<<"7,金币小礼包*"<<jingxiaolibao<<" 8,金币大礼包*"<<jingdalibao<<endl;
cout<<"9,返回主界面"<<endl;
cin>>g;
if(g==1){
   
if(xuexiaolibao>0){
   
cout<<"恭喜获得10点血量";
xueliang=xueliang+10;
xuexiaolibao=xuexiaolibao-1;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
else{
   
cout<<"你暂无该礼包"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
}
if(g==2){
   
if(xuedalibao>0){
   
cout<<"恭喜获得50点血量";
xueliang=xueliang+50;
xuedalibao=xuedalibao-1;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
else{
   
cout<<"你暂无该礼包"<<endl;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
}
if(g==3){
   
if(wuxiaolibao>0){
   
cout<<"恭喜获得10点攻击力";
gongjili=gongjili+10;
wuxiaolibao=wuxiaolibao-1;
cout<<"按任意键继续"<<endl;
getch();
system("cls");
}
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值