[C++] 小游戏 能量 1.1.2 正式版
2025-06-24 12:03:13
来源:新华网
目录
前言
演示用编译器及其标准
Dev C++ 6.7.5 Red panda
标准:C++14
宣团
先 赞 后 看 养 成 习 惯
正文
更新日志:
游戏演示视频
游戏截图
还有我们最最最重要的游戏代码(zty求你了给个赞呗)
后记
作者有话要说
前言
今天zty带来的是C++ 小游戏 能量的 1.1.2 正式版 ,zty 放假了更新也是会增加的,大胆的要赞(做白日梦),我想要100个赞(癞蛤蟆想吃天鹅肉)
先 赞 后 看 养 成 习 惯
众所周知,一篇文章需要一个头图,但我家盛产头图
先 赞 后 看 养 成 习 惯
上面那行字怎么读呢,让大家来跟我一起读一遍吧,先~赞~后~看~养~成~习~惯~
演示用编译器及其标准
Dev C++ 6.7.5 Red panda
标准:C++14
编译器下载点我
宣团
洛谷宣团
我想要这个 →
先 赞 后 看 养 成 习 惯
正文
zty 求你了,给个赞呗qwq
更新日志:
1 ,加强调试模式的功能,使其可以更方便快捷的找到出现问题的地方并及时修改,如果你不是专门想去找问题的话,开着调试模式来玩游戏可能会影响你的游戏体验。
2 ,将大部分输入改为getch输入方法,使你可以更方便更快捷的来选出你所想要选择功能。
3, 修改炼狱模式游戏数值无法保存的bug,把炼狱模式的游戏数值也写到了存档里面,不要试图偷偷修改你的存档,因为它有可能会让你的程序直接崩溃爆炸。
4, 一些极小的辅助功能的修改,其中包括那一些格式的修改、一些文字的修改和代码的优化。
5, 1个彩蛋,这个彩蛋是不会直接看到,但如果你在某些界面输入 “7” (不包括双引号),你有可能会触发这个彩蛋。
游戏演示视频
这个,CSDN那个老登审核过了视频他还是不让我挂,只能用链接了
游戏截图
还有我们最最最重要的游戏代码(zty求你了给个赞呗)
/*游戏规则在游戏中有详解。更新日志1 加强以加强调试模式的功能。2 将大部分输入改为getch输入方法。3 修改炼狱模式游戏数值无法保存的bug。4 一些极小的辅助功能的修改。5 1个彩蛋。*/#include#include#include#include#include#include#include#include //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(15); }}void yxzt(int);void cd();void ckzj();void gyyx() { system("cls"); print(" 您好,欢迎您玩能量。为了给您更好的游戏体验,zty时不时会优化本游戏,优化后会尽快发布在网上(CSDN)。我在 1.1.2 正式版内容的基础上进行改进,主要内容为加强调试模式的功能、全部改用getch输入、修改炼狱模式游戏数值无法保存的bug和一些细小的辅助修改,已更新完毕,希望大家喜欢。作者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\n\t 炼狱总场数:" << lyzong << "\t\t炼狱胜场数:" << lysheng << "\t\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()); if (s == 4) lybai = atoi(str.c_str()); if (s == 5) lysheng = atoi(str.c_str()); if (s == 6) lyzong = 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) { if (tiaoshi) { cout << "Artificial intelligence has gone through a cycle"; Sleep(500); } dichuhs++; dichuhs = dichuhs % 6 + 1; if (lun == 1) { if (tiaoshi) { cout << "Artificial Intelligence Direct Selection " << 4; Sleep(500); } return 4; } if (dineng >= 3) { if (tiaoshi) { cout << "Artificial Intelligence Direct Selection " << 3; Sleep(500); } return 3; } if (neng == 0 && dineng == 0) { if (tiaoshi) { cout << "Artificial Intelligence Direct Selection " << 4; Sleep(500); } return 4; }// cout << dichuhs << endl; if (neng == 0 && dichuhs == 5) { if (tiaoshi) { cout << "Artificial intelligence uses algorithms to skip this round"; Sleep(500); } continue; } if (dineng == 1 && dichuhs == 2 || dineng <= 2 && dichuhs == 3) { continue; } else if (dineng < 1 && dichuhs < 4) { if (tiaoshi) { cout << "Artificial intelligence uses algorithms to skip this round"; Sleep(500); } continue; } else if (neng < 2 && dichuhs == 6) { if (tiaoshi) { cout << "Artificial intelligence uses algorithms to skip this round"; Sleep(500); } continue; } else if (neng == 0 && dichuhs == 5) { if (tiaoshi) { cout << "Artificial intelligence uses algorithms to skip this round"; Sleep(500); } continue; } else if (neng == 0 && dichuhs == 6) { if (tiaoshi) { cout << "Artificial intelligence uses algorithms to skip this round"; Sleep(500); } continue; } else { if (tiaoshi) { cout << "Artificial intelligence selects through algorithms" << dichuhs << endl; } return dichuhs; } }}void ts(int lun, int neng) { //战斗提示 cout << "\n第" << lun << "轮" << endl << "1:波 2:海啸 3:天雷 4:能量 5:防(波) 6:防(海啸) 0:返回菜单 \n能量:" << 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) { dd: 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 = _getch(); xuan -= 48;// cin >> xuan; if (tiaoshi) cout << xuan; int xxuan = 0; switch (xuan) { case 1: system("cls"); system("color 8E"); cout << "\n\n================================================================================\n\t\t"; print(" 1,简单难度 2,炼狱难度 0,返回上一级"); cout << "\n\n================================================================================\n\t\t";// cin >> xxuan;// cout<= 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< digong && gong != difang) || (dichu == 4 && gong > 0) || (dichu == 4 && gong != 0)) { cout << "YOU WIN!\n\n"; if (zuobi) { cout << "你居然还要用作弊来刷战绩!哈哈。早就被作者料到了。这次游戏不增加战绩。\n"; system("pause"); return; } 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 (zuobi) { cout << "你居然还要用作弊来刷战绩!哈哈。早就被作者料到了。这次游戏不增加战绩。\n"; system("pause"); return; } if (lyly) { lyzong++; lybai++; } else { zong++; bai++; } bccd(zong, sheng, bai); system("pause"); return; } } return;}//▆void Start() { system("color 8E"); cout << " \n"; cout << " ■ ■ ■ ■■■■■■ \n"; cout << " ■ ■ ■ ■■ ■ ■ \n"; cout << " ■■■■ ■■ ■■■■■■ \n"; cout << " ■ ■ ■ ■ ■ \n"; cout << " ■■■■ ■■■ ■■■■■■ \n"; cout << " ■ ■ ▆▆▆▆▆▆▆▆▆▆▆▆ \n"; cout << " ■■■■ ■ ■ \n"; cout << " ■ ■ ■ ■■ ■■■■■ \n"; cout << " ■■■■ ■■ ■ ■ ■ \n"; cout << " ■ ■ ■ ■■■■■ \n"; cout << " ■ ■■ ■ ■ ■ ■ ■ \n"; cout << " ■ ■■■■ ■■■■■ \n"; cout << " ■ \n"; cout << " 欢迎来到 [能量] ■■■■■ \n"; cout << " ■ \n"; cout << " 1.1.2 正式版 ■■■■■■■■ \n"; cout << " \n"; cout << " zty出品,必属精品 \n"; cout << " \n"; cout << " zty郑桐羽呀出品 \n"; cout << " \n"; cout << " 输入“1 ”下一页 zty出品 \n\n";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"; cout << " ■ ■■■ ■■■ ■ ■ \n"; cout << " ■■ ■ ■ ■ ■ ■ \n"; cout << " ■ ■ ■ ■ ■ \n"; cout << " ■ ■■ ■ ■ ■ \n"; cout << " ■ ■ ■ ■ ■ ■ \n"; cout << " ■■■ ■■ ■■■ \n"; cout << " ■ \n"; cout << " ■ ■ \n"; cout << " 欢迎来到 [能量] ■ ■ \n"; cout << " ■■ \n"; cout << " zty郑桐羽呀出品 ■ \n"; cout << " ■ ■ ■ ■■■■ \n"; cout << " 1.1.2 正式版 ■■■■■ ■ ■ \n"; cout << " ■ ■■■■ \n"; cout << " zty出品专属水印 ■ ■ ■ \n"; cout << " ■■■■■ ■■■ ■■■ \n"; cout << " zty出品,必属精品 ■ ■ ■ ■ \n"; cout << " ■■■ ■■■ \n"; cout << " 抵制盗版 侵权必究 \n"; cout << " \n"; cout << " 输入“1 ”开始游戏 \n\n";A: char y = _getch(); if (y == '1') return; else goto A;}int main() { system("title 能量 1.1.2 zty出品"); system("mode con cols=80 lines=25"); Start(); Start2(); Bling(); drcd(); cd(); return 0;}
后记
作者:zty郑桐羽呀
联系方式:(不挂了,有事私信)
兄弟们给个赞呗
作者有话要说
刚才看了一下粉丝画像啊,我女粉居然比男粉还要多,女粉1200男粉才800,当然他这个说的不准确不过这个比例应该是对的,还有zty要在这个寒假的话开始狂更新,求点赞求收藏求关注qwq
先 赞 后 看 养 成 习 惯