[C++] 小游戏 能量1.0.2版本 zty出品

大家好,欢迎来到今天的代码。我很荣幸能够在这里与大家见面。今天我想向大家介绍的是能量1.0.2版本。本次主要更新了人工智障的智商,没有以前那么笨了。++先赞后看 养成习惯++

CODE

cpp 复制代码
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int rgzz(int lun, int dineng, int neng){
	while(1){//人工智障系统
			int dichu=0;
            if(lun==1){
            	return 4;
			}
			if(dineng==3){
				return 3;
			} 
			srand(time(0));
    		dichu=rand()%5+1;
    		if(dineng==1&&dichu==2||dineng<=2&&dichu==3) continue;
    		else if(dineng<1&&dichu<4) continue;
    		else if(neng>2&&dichu==6) continue;
    		else if(neng<1&&dichu>4) continue;
			else return dichu;
		}
}
void ts(int lun,int neng){
	cout<<"第"<<lun<<"轮"<<endl<<"1:波  2:海啸  3:天雷  4:能量  5:防(波)  6:防(海啸) 0:退出游戏  能量:"<<neng<<endl;
	return;
}
void Bling(){
    for(int i=0;i<=3;i++){
        system("color 1A");Sleep(40);
        system("color 2B");Sleep(40);
        system("color 3C");Sleep(40);
        system("color 4D");Sleep(40);
        system("color 5D");Sleep(40);
        system("color 6E");Sleep(40);
        system("color 7F");Sleep(40);
    }
}
int main(){
	cout<<"欢迎游玩"能量"小游戏\n";
	Bling();
	system("color 8E");
	int neng=0,dineng=0,lun=0;
	while(1){
		int gong=0,fang=0,digong=0,difang=0,chu=0,dichu=0;
		lun++;
		ts(lun,neng);
		cin>>chu;
    	switch(chu){//玩家控制
			case 1:	  if(neng>=1){gong=1;neng--;cout<<"我:\n波"<<endl;}else{cout<<"没有足够的能量"<<endl;;lun--;continue;}break;
			case 2:	  if(neng>=2){gong=2;neng-=2;cout<<"我:\n海啸"<<endl;}else{cout<<"没有足够的能量"<<endl;lun--;continue;}break;
			case 3:	  if(neng>=3){gong=3;neng-=3;cout<<"我:\n天雷"<<endl;}else{cout<<"没有足够的能量"<<endl;lun--;continue;}break;
			case 4:	  neng++;cout<<"我:\n能量"<<endl;break;
			case 5:	  fang=1;cout<<"我:\n波防"<<endl;break;
			case 6:	  fang=2;cout<<"我:\n海啸防"<<endl;break;
			case 0:   return 0;
		}
		dichu=rgzz(lun,dineng,neng);
		cout<<"敌:"<<endl;
		switch(dichu){//机器控制
			case 1:	  digong=1;dineng--;cout<<"波"<<endl;break;
			case 2:	  digong=2;dineng-=2;cout<<"海啸"<<endl;break;
			case 3:	  digong=3;dineng-=3;cout<<"天雷"<<endl;break;
			case 4:	  dineng++;cout<<"能量"<<endl;break;
			case 5:	  difang=1;cout<<"波防"<<endl;break;
			case 6:	  difang=2;cout<<"海啸防"<<endl;break;
		}
	    if((gong==difang&&gong!=0) || chu==dichu || (digong==fang&&digong!=0)) continue;//判断游戏是否结束
	    else if((gong>digong&&gong!=difang) || (dichu==4&&gong>0) || (dichu==4&&gong!=0)){
	    	cout<<"YOU WIN!\n\n";
	    	return 0;
		}else if((digong>gong&&digong!=fang) || (digong!=fang&&digong!=0) || (chu==4&&digong>0)){
			cout<<"YOU DIE!\n\n";
        	return 0;
		}
	}
	return 0;
}

++我的赞呢 你看见了吗++

作者:zty郑桐羽呀

联系方式:(不挂了,有事私信)

相关推荐
心情好的小球藻3 分钟前
Python应用进阶DAY9--类型注解Type Hinting
开发语言·python
惜.己15 分钟前
使用python读取json数据,简单的处理成元组数组
开发语言·python·测试工具·json
Y40900121 分钟前
C语言转Java语言,相同与相异之处
java·c语言·开发语言·笔记
古月-一个C++方向的小白6 小时前
C++11之lambda表达式与包装器
开发语言·c++
沐知全栈开发6 小时前
Eclipse 生成 jar 包
开发语言
杭州杭州杭州7 小时前
Python笔记
开发语言·笔记·python
tanyongxi668 小时前
C++ AVL树实现详解:平衡二叉搜索树的原理与代码实现
开发语言·c++
阿葱(聪)9 小时前
java 在k8s中的部署流程
java·开发语言·docker·kubernetes
浮生带你学Java9 小时前
2025Java面试题及答案整理( 2025年 7 月最新版,持续更新)
java·开发语言·数据库·面试·职场和发展
斯是 陋室9 小时前
在CentOS7.9服务器上安装.NET 8.0 SDK
运维·服务器·开发语言·c++·c#·云计算·.net