前言
今天zty带来的是能量 1.1.1 版本,好久没出游戏啦,大家给个赞呗,zty还要上学,发作品会少一点
先 赞 后 看 养 成 习 惯
先 赞 后 看 养 成 习 惯
演示用编译器及其标准
编译器:Dev C++ 6.7.5 Red panda
标准:C++14
同款编译器下载点我
能量 1.1.1 版本 cpp 文件下载点我
先 赞 后 看 养 成 习 惯
正文
更新日志:
1 . 炼狱游戏难度
2 . 调试模式
3 . 新的游戏介绍
4 . 可在游戏中查看作者
5 . 炼狱人工智能
6 . 游戏设置
游戏截图:
演示视频
<iframe allowfullscreen="true" data-mediaembed="csdn" frameborder="0" id="U6ZOn3oR-1734083600081" src="https://live.csdn.net/v/embed/438733"></iframe>能量1.1.1 演示视频
code
#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<ctime>
#include<conio.h>
#include<time.h>
#include<cmath>
#include<windows.h> //SLEEP函数
using namespace std;
bool lianyu;
bool tiaoshi = 0;
int lysheng, lybai, lyzong;
int zong, sheng, bai;
void print(string text) {
for (int i = 0; i < text.size(); i++) {
cout << text[i];
Sleep(30);
}
}
void yxzt(int);
void cd();
void ckzj();
void gyyx() {
system("cls");
print(" 您好,欢迎您玩能量。为了给您更好的游戏体验,zty时不时会优化本游戏,优化后会尽快发布在网上(CSDN)。我在1.0版本内容的基础上进行改进主要内容为加入《炼狱游戏难度》、调试模式和一些辅助游戏的功能,已更新完毕,希望大家喜欢。作者CSDN名:zty郑桐羽呀(其他都是盗版)\n\n\n\n");
system("color 8E");
system("pause");
return;
}
void yxgz() {
system("cls");
cout << "游戏规则:\n\n 1,波(消耗1点能量,可被<波>和<波防>防下,可被<海啸><天雷>打回)是攻击技能\n\n ";
cout << "2,海啸(消耗2点能量,可被<海啸>和<海啸防>防下,可被<天雷>打回)是攻击技能\n\n ";
cout << "3,天雷(消耗3点能量,可被<天雷>防下,不可被打回)是攻击技能\n\n ";
cout << "4,能量(增加1点能量(10轮后为2点),可被<波><海啸><天雷>打回)是其他技能\n\n ";
cout << "5,波防(不消耗能量,可防下<波>,可被<海啸><天雷>打回)是防守技能\n\n ";
cout << "6,海啸防(不消耗能量,可防下<海啸>,可被<波><天雷>打回)是防守技能\n\n ";
cout << "7,如果自己使用的技能被打回,则失败;如果敌人使用的技能被打回,则胜利。\n\n ";
cout << "8,如果自己或敌人使用的技能被防下,则跳过本轮。\n\n ";
cout << "9,如果双方使用的是同一个技能或都不是攻击技能,则跳过本轮。\n ";
system("pause");
return;
}
void ckzj(int zong, int sheng, int bai) { //查看战绩
system("cls");
cout << "\n\n================================================================================\n\n\t 总场数:" << zong;
cout << "\t\t胜场数:" << sheng;
cout << "\t\t败场数:" << bai;
cout << "\n\t 炼狱总场数:" << lyzong << "\t炼狱胜场数:" << lysheng << "\t炼狱败场数:" << lybai;
cout << "\n\n\n================================================================================";
system("pause");
return;
}
void drcd() { //读入存档
string line;
fstream myFile;
int s = 0;
myFile.open("能量存档.txt", ios::in); // read,读
if (myFile.is_open()) {
while (getline(myFile, line)) {
string str(line);
s++;
if (s == 1)
bai = atoi(str.c_str());
if (s == 2)
sheng = atoi(str.c_str());
if (s == 3)
zong = atoi(str.c_str());
}
myFile.close();
}
}
int lyzn(int lun, int wochu, int dineng) {
if (lun == 1) {
return 4;
} else if (wochu == 1) {
return 5;
} else if (wochu == 5 && dineng >= 2) {
return 2;
} else if (wochu == 6 && dineng >= 1) {
return 1;
} else if (wochu == 2) {
return 6;
} else if (wochu == 4 && dineng != 0) {
return 1;
} else {
return 4;
}
}
int rgzz(int lun, int dineng, int neng) {//人工智障系统
// cout << "Artificial Intelligence Function" << endl;
srand(time(0));
int dichuhs = 0;
dichuhs = rand() % 6 + 1;
while (1) {
dichuhs++;
dichuhs=dichuhs%6+1;
if (lun == 1) {
return 4;
}
if (dineng >= 3) {
return 3;
}
if (neng == 0 && dineng == 0) {
return 4;
}
// cout << dichuhs << endl;
if (neng == 0 && dichuhs == 5) {
continue;
}
if (dineng == 1 && dichuhs == 2 || dineng <= 2 && dichuhs == 3) continue;
else if (dineng < 1 && dichuhs < 4) continue;
else if (neng < 2 && dichuhs == 6) continue;
else if (neng == 0 && dichuhs == 5) continue;
else if (neng == 0 && dichuhs == 6) continue;
else {
if (tiaoshi) {
cout << "Artificial Intelligence has chosen" << dichuhs << endl;
}
return dichuhs;
}
}
}
void ts(int lun, int neng) { //战斗提示
cout << "\n第" << lun << "轮" << endl << "1:波 2:海啸 3:天雷 4:能量 5:防(波) 6:防(海啸) 0:返回菜单 能量:" << neng << endl;
return;
}
int yxsz() {
sz:
int xuan;
system("cls");
system("color 8E");
int ii;
cout << "\n\n================================================================================\n\t\t";
print(" 1,清空战绩 2,打开调试 3,退出游戏\n\t\t\t\t 输入‘0 ’以返回上一级");
cout << "\n\n================================================================================\n\t\t";
xuan = _getch();
if (xuan == 1) {
system("cls");
cout << "真的吗?1(真的)/0(按错了)\n";
cin >> ii;
if (!ii) {
goto sz;
}
zong = 0;
sheng = 0;
bai = 0;
char line[256];
fstream myFile;
myFile.open("能量存档.txt", ios::out);
if (myFile.is_open()) {
myFile << bai << "\n";
myFile << sheng << "\n";
myFile << zong << "\n";
myFile.close();
}
} else if (xuan == 2) {
if (tiaoshi) {
cout << "\n\tDebugging mode has been enabled\n";
tiaoshi = 1;
} else {
cout << "\n\tDebugging mode has been turned off\n";
tiaoshi = 0;
}
} else if (xuan == 3) {
return 0;
} else if (xuan == 0) {
return 1;
}
return 1;
}
int ly;
void cd() {//游戏菜单
while (1) {
system("cls");
system("color 8E");
ly = 0;
cout << "\n\n================================================================================\n\t\t 1,开始游戏 2,查看战绩 3,查看规则\n\n\t\t 4,关于游戏 5,游戏设置 6,查看作者\n\n================================================================================";
int xuan;
cin >> xuan;
int xxuan = 0;
switch (xuan) {
case 1:
system("cls");
system("color 8E");
cout << "\n\n================================================================================\n\t\t";
print(" 1,简单难度 2,炼狱难度");
cout << "\n\n================================================================================\n\t\t";
cin >> xxuan;
// cout<<xxuan;
Sleep(1000);
if (xxuan == 2) {
ly = 1;
yxzt(1);
system("color 84");
} else {
ly = 0;
yxzt(0);
}
break;
case 2:
ckzj(zong, sheng, bai);
break;
case 3:
yxgz();
break;
case 4:
gyyx();
break;
case 5:
if (!yxsz()) {
return;
}
break;
case 6:
system("start https://blog.csdn.net/zty20120913?type=lately");
system("cls");
break;
default:
printf("无该选项!\n\n\n");
Sleep(300);
}
}
return;
}
void bccd(int zong, int sheng, int bai) { //保存存档
char line[256];
fstream myFile;
myFile.open("能量存档.txt", ios::out);
if (myFile.is_open()) {
myFile << bai << "\n";
myFile << sheng << "\n";
myFile << zong << "\n";
myFile.close();
}
}
void Bling() { //开始动画
for (int i = 0; i <= 1; 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);
}
}
void yxzt(int lyly) { //游戏主体
system("cls");
int neng = 0, dineng = 0, lun = 0;
while (1) {
int gong = 0, fang = 0, digong = 0, difang = 0, chu = 0, dichu = 0, sneng;
if (lyly == 1) {
system("color 84");
// cout << "ly";
}
lun++;
sneng = neng;
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:
// cout<<lun;
if (lun < 10) {
neng++;
} else {
neng += 2;
}
cout << "我:\n能量" << endl;
break;
case 5:
fang = 1;
cout << "我:\n波防" << endl;
break;
case 6:
fang = 2;
cout << "我:\n海啸防" << endl;
break;
case 0:
cd();
default:
printf("无该选项!\n\n\n");
Sleep(300);
lun--;
continue;
}
if (lyly == 1) {
dichu = lyzn(lun, chu, dineng);
}
if (lyly == 0) dichu = rgzz(lun, dineng, sneng);
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:
if (lun < 10) {
dineng++;
} else {
dineng += 2;
}
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";
if (lyly) {
lyzong++;
lysheng++;
} else {
zong++;
sheng++;
}
bccd(zong, sheng, bai);
system("pause");
return;
} else if ((digong > gong && digong != fang) || (digong != fang && digong != 0) || (chu == 4 && digong > 0)) {
cout << "YOU DIE!\n\n";
if (lyly) {
lyzong++;
lybai++;
} else {
zong++;
bai++;
}
bccd(zong, sheng, bai);
system("pause");
return;
}
}
return;
}
//▆
void Start() {
system("color 8E");
cout << " \n";
cout << " ■ ■ ■ ■■■■■■ \n";
Sleep(50);
cout << " ■ ■ ■ ■■ ■ ■ \n";
Sleep(50);
cout << " ■■■■ ■■ ■■■■■■ \n";
Sleep(50);
cout << " ■ ■ ■ ■ ■ \n";
Sleep(50);
cout << " ■■■■ ■■■ ■■■■■■ \n";
Sleep(50);
cout << " ■ ■ ▆▆▆▆▆▆▆▆▆▆▆▆ \n";
Sleep(50);
cout << " ■■■■ ■ ■ \n";
Sleep(50);
cout << " ■ ■ ■ ■■ ■■■■■ \n";
Sleep(50);
cout << " ■■■■ ■■ ■ ■ ■ \n";
Sleep(50);
cout << " ■ ■ ■ ■■■■■ \n";
Sleep(50);
cout << " ■ ■■ ■ ■ ■ ■ ■ \n";
Sleep(50);
cout << " ■ ■■■■ ■■■■■ \n";
Sleep(50);
cout << " ■ \n";
Sleep(50);
cout << " 欢迎来到 [能量] ■■■■■ \n";
Sleep(50);
cout << " ■ \n";
Sleep(50);
cout << " 1.1.1 正式版 ■■■■■■■■ \n";
Sleep(50);
cout << " \n";
Sleep(50);
cout << " zty出品,必属精品 \n";
Sleep(50);
cout << " \n";
Sleep(50);
cout << " zty郑桐羽呀出品 \n";
Sleep(50);
cout << " \n";
Sleep(50);
cout << " 输入“1 ”下一页 zty出品 \n\n";
Sleep(50);
A:
char y = _getch();
if (y == '1') return;
else goto A;
}
void Start2() {
system("color 8E");
system("cls");
if (sheng == 1) Beep(3200, 50);
cout << " \n";
Sleep(50);
cout << " ■ ■■■ ■■■ ■ ■ \n";
Sleep(50);
cout << " ■■ ■ ■ ■ ■ ■ \n";
Sleep(50);
cout << " ■ ■ ■ ■ ■ \n";
Sleep(50);
cout << " ■ ■■ ■ ■ ■ \n";
Sleep(50);
cout << " ■ ■ ■ ■ ■ ■ \n";
Sleep(50);
cout << " ■■■ ■■ ■■■ \n";
Sleep(50);
cout << " ■ \n";
Sleep(50);
cout << " ■ ■ \n";
Sleep(50);
cout << " 欢迎来到 [能量] ■ ■ \n";
Sleep(50);
cout << " ■■ \n";
Sleep(50);
cout << " zty郑桐羽呀出品 ■ \n";
Sleep(50);
cout << " ■ ■ ■ ■■■■ \n";
Sleep(50);
cout << " 1.1.1 正式版 ■■■■■ ■ ■ \n";
Sleep(50);
cout << " ■ ■■■■ \n";
Sleep(50);
cout << " zty出品专属水印 ■ ■ ■ \n";
Sleep(50);
cout << " ■■■■■ ■■■ ■■■ \n";
Sleep(50);
cout << " zty出品,必属精品 ■ ■ ■ ■ \n";
Sleep(50);
cout << " ■■■ ■■■ \n";
Sleep(50);
cout << " 抵制盗版 侵权必究 \n";
Sleep(50);
cout << " \n";
Sleep(50);
cout << " 输入“1 ”开始游戏 \n\n";
Sleep(50);
A:
char y = _getch();
if (y == '1') return;
else goto A;
}
int main() {
system("title 能量 1.1.1 zty出品");
system("mode con cols=80 lines=25");
Start();
Start2();
Bling();
drcd();
cd();
return 0;
}
后记
作者:zty郑桐羽呀
联系方式:(不挂了,有事私信)
兄弟们给个赞呗
先 赞 后 看 养 成 习 惯
标签:gong,return,1.1,int,C++,小游戏,&&,include,cout From: https://blog.csdn.net/zty20120913/article/details/144404824