[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郑桐羽呀

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

相关推荐
昵称画1 小时前
交接班记录电子化:三班之间的信息不漏
开发语言·数据库·人工智能·低代码·php
“AI国潮设计-小江”2 小时前
【AIGC实战】Python+SDXL批量生成“潮汕英歌舞不倒翁”IP | 角色一致性与多场景融合方案,附完整代码
开发语言·人工智能·python·prompt·aigc
传奇开心果编程2 小时前
【Rust入门练中学】第6课:结构体与方法
开发语言·rust·结构体·编程语言理论·结构体方法·编程通用语言
code tsunami2 小时前
【无标题】
开发语言·python
CodeGL3 小时前
10、Python基础之进程和线程
开发语言·python
hetao17338373 小时前
2026-10-22~23 hetao1733837 的刷题记录
c++·算法
TechWayfarer4 小时前
PHP漏洞被利用,怎么揪出攻击IP?
开发语言·python·tcp/ip·网络安全·php
王老师青少年编程4 小时前
2025年6月GESP真题及题解(C++三级): 选择题和判断题(题解)
c++·真题·gesp·答案·csp·三级·信奥赛
卡卡~~5 小时前
“101计划”核心课程实践教材《数据实验结构指导-C++语言版》题目集
开发语言·c++·学习·算法
qq_406981035 小时前
大白话rust系列09 函数调用两次有什么错?
开发语言·python·rust