欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

C++冒险挖矿[0.6版本]

时间:2023-04-29

目录

QQ:3585914757

前言

游戏玩法

后续发展

代码实操

好了,再见!


前言

嗨!最近开学了,更得要慢一些。所以,在经过半年多(真的)的努力下,出了这个新的系列。

创作它的灵感来源来自小艺上的一个同名游戏——“冒险挖矿”。这是我去年做的(所以说有半年多),但做了一半就丢下了,后来又觉得可以再拯救一下,于是又拯救起来了。

但正是因为是拯救起来的,所以没做太大的改动,完全没用到类之类的,比我还小白的小白不用注释也看得懂。

游戏玩法

一.关键词
1.向下、向左、向右:下、左、右
2.去某个星球:去(哪里,星球分别有地球、月球、火星、泰坦星、金银星,此处按危险程度排序,在越危险的地方遇到金币,金币将会更多)
3.抹掉存档:抹掉
4.确认:是、好、要      取消:其它短语均可
5.帮助:帮助
6.输入无关内容,将跳过
二.关于挖矿
1.在第0米处只能往下挖
三.其它
1.游戏将自动保存!
如有游戏bug或其它问题,请加QQ:3585914757

后续发展

我会把这个游戏做丰富一些,目前大概也就上述功能,后续会有一个“反修改存档”机制(我很“机智”吧!);优化目前的“空箱子”,可以获得一些物品;还有就是商店和装备(最扣脑阔的东西,所以要很久才能更新)。如果你们喜欢,我还会再添加一些功能;甚至——整个(只是达到)可视化的地图(已经很难了,别再说丰富地图了);再说,如果真的要做出来——我写这篇文章时才11岁!

代码实操

#include #include #include #include using namespace std;int planet = 1, depth = 0, coins = 0, pointofskills = 0, playerlifevalue = 10, playeraggressivity = 1, headarmorvalue = 0, bodyarmorvalue = 0, legarmorvalue = 0;int knapsack[15] = { 0 };string instructions;int auxiliary = 0;void rne(int minimum_1_1, int biggest_1_1, int minimum_1_2, int biggest_1_2, int minimum_2_1, int biggest_2_1, int minimum_2_2, int biggest_2_2, int minimum_3_1, int biggest_3_1, int minimum_3_2, int biggest_3_2, int minimum_4, int biggest_4, int monsterhealthvalue, int monsteraggressivity){auxiliary = rand() % 100 + 1;cout << auxiliary << endl;if (auxiliary >= minimum_1_1 && auxiliary <= biggest_1_1){srand(time(0));auxiliary = rand() % (biggest_1_2 - minimum_1_2 + 1) + minimum_1_2;cout << "你挖到了" << auxiliary << "个金币。" << endl;coins += auxiliary;}if (auxiliary >= minimum_2_1 && auxiliary <= biggest_2_1){srand(time(0));auxiliary = rand() % (biggest_2_2 - minimum_2_2 + 1) + minimum_2_2;cout << "你找到了" << auxiliary << "个技能点。" << endl;pointofskills += auxiliary;}if (auxiliary >= minimum_3_1 && auxiliary <= biggest_3_1){srand(time(0));auxiliary = rand() % (biggest_3_2 - minimum_3_2 + 1) + minimum_3_2;if (auxiliary > coins)auxiliary = coins;if (auxiliary == 0){cout << "你挖到了一个空箱子。" << endl;}else{cout << "你踩到了一个炸弹,丢了" << auxiliary << "个金币。" << endl;coins -= auxiliary;}}if (auxiliary >= minimum_4 && auxiliary <= biggest_4){if (monsterhealthvalue / playeraggressivity <= (playerlifevalue + headarmorvalue + bodyarmorvalue + legarmorvalue) / monsteraggressivity){auxiliary = (monsterhealthvalue / playeraggressivity) * monsteraggressivity - (headarmorvalue + bodyarmorvalue + legarmorvalue);if (auxiliary < 0)auxiliary = 0;cout << "你遇到了一只怪兽,你杀死了它,获得了" << playerlifevalue + playeraggressivity + headarmorvalue + bodyarmorvalue + legarmorvalue << "个金币,剩余" << playerlifevalue - auxiliary << "点生命。" << endl;playerlifevalue -= auxiliary;coins += (playerlifevalue + playeraggressivity + headarmorvalue + bodyarmorvalue + legarmorvalue);}else{cout << "你在与怪兽战斗时死了。" << endl;planet = 1, depth = 0, coins = 0, pointofskills = 0, playerlifevalue = 10, playeraggressivity = 1, headarmorvalue = 0, bodyarmorvalue = 0, legarmorvalue = 0;}}}bool in(string str_chatter, string str_chatterBot){if (str_chatter.find(str_chatterBot) != string::npos){return true;}else{return false;}}void gt(int dplanet){if (coins >= dplanet * 2000){cout << "去" << (dplanet == 1 ? "地球" : "") << (dplanet == 2 ? "月球" : "") << (dplanet == 3 ? "火星" : "") << (dplanet == 4 ? "泰坦星" : "") << (dplanet == 5 ? "金银星" : "") << "需要" << (dplanet == 1 ? "2000" : "") << (dplanet == 2 ? "4000" : "") << (dplanet == 3 ? "6000" : "") << (dplanet == 4 ? "8000" : "") << (dplanet == 5 ? "10000" : "") << "个金币,你有" << coins << "个金币,要前往吗?" << endl;cin >> instructions;if (in(instructions, "是")|| in(instructions, "好")|| in(instructions, "要")){system("cls");coins -= dplanet * 2000;planet = dplanet;cout << "您已到达" << (planet == 1 ? "地球" : "") << (planet == 2 ? "月球" : "") << (planet == 3 ? "火星" : "") << (planet == 4 ? "泰坦星" : "") << (planet == 5 ? "金银星" : "") << "!" << endl;}else{system("cls");cout << "好的!" << endl;}}else{cout << "去" << (dplanet == 1 ? "地球" : "") << (dplanet == 2 ? "月球" : "") << (dplanet == 3 ? "火星" : "") << (dplanet == 4 ? "泰坦星" : "") << (dplanet == 5 ? "金银星" : "") << "需要" << dplanet * 2000 << "个金币,你只有" << coins << "个金币,无法前往!" << endl;}}void read(){ifstream in("save.dll");in >> planet >> depth >> coins >> pointofskills >> playerlifevalue >> playeraggressivity >> headarmorvalue >> bodyarmorvalue >> legarmorvalue;in.close();}void save(){ofstream out("save.dll");out << planet << " " << depth << " " << coins << " " << pointofskills << " " << playerlifevalue << " " << playeraggressivity << " " << headarmorvalue << " " << bodyarmorvalue << " " << legarmorvalue;out.close();}int main(){system("color F0");srand((unsigned int)time(NULL));while (true){read();cout << "欢迎来到冒险挖矿!" << endl;cout << "你现在在" << (planet == 1 ? "地球" : "") << (planet == 2 ? "月球" : "") << (planet == 3 ? "火星" : "") << (planet == 4 ? "泰坦星" : "") << (planet == 5 ? "金银星" : "") << ",挖了" << depth << "米" << ",有" << coins << "个金币" << "和" << pointofskills << "个技能点" << endl;cout << "请问你想干什么?" << endl;cin >> instructions;if (in(instructions, "下") || in(instructions, "左") || in(instructions, "右")){if (depth == 0 && in(instructions, "左") || in(instructions, "右")){system("pause");system("cls");save();continue;}if (in(instructions, "下")){depth++;}if (planet == 1){if (depth <= 50){rne(1, 70, 1, 10, 71, 80, 1, 10, 81, 95, 1, 10, 96, 100, 2, 1);}else{rne(1, 60, 1, 15, 61, 80, 1, 15, 81, 95, 1, 20, 96, 100, 5, 2);}}if (planet == 2){if (depth <= 50){rne(1, 65, 10, 20, 66, 75, 10, 20, 76, 90, 15, 20, 91, 100, 8, 3);}else{rne(1, 60, 10, 25, 61, 75, 10, 25, 76, 90, 20, 30, 91, 100, 10, 3);}}if (planet == 3){if (depth <= 50){rne(1, 60, 30, 100, 61, 80, 1, 20, 81, 95, 1, 80, 96, 100, 30, 5);}else{rne(1, 75, 40, 110, 76, 85, 20, 50, 86, 99, 1, 30, 100, 100, 50, 10);}}if (planet == 4){if (depth <= 50){rne(1, 60, 55, 120, 56, 65, 30, 60, 66, 80, 50, 100, 81, 100, 100, 15);}else{rne(1, 40, 80, 150, 41, 60, 50, 80, 61, 80, 80, 100, 81, 100, 150, 20);}}if (planet == 5){if (depth <= 50){rne(1, 10, 100, 200, 11, 20, 100, 200, 21, 80, 150, 250, 81, 100, 200, 20);}else{rne(1, 10, 150, 250, 11, 20, 150, 250, 21, 80, 200, 400, 81, 100, 500, 100);}}}else if (in(instructions, "去")){if (in(instructions, "地球")){if (planet == 1){cout << "你已经在地球了哦!" << endl;}else{system("cls");gt(1);}}if (in(instructions, "月球")){if (planet == 2){cout << "你已经在月球了哦!" << endl;}else{system("cls");gt(2);}}if (in(instructions, "火星")){if (planet == 3){cout << "你已经在火星了哦!" << endl;}else{system("cls");gt(3);}}if (in(instructions, "泰坦星")){if (planet == 4){cout << "你已经在泰坦星了哦!" << endl;}else{system("cls");gt(4);}}if (in(instructions, "金银星")){if (planet == 5){cout << "你已经在金银星了哦!" << endl;}else{system("cls");gt(5);}}}else if (in(instructions, "抹掉")){cout << "确定要抹掉存档吗?" << endl;cin >> instructions;if (in(instructions, "是") || in(instructions, "好") || in(instructions, "要")){ofstream in("save.dll");in.close();planet = 1, depth = 0, coins = 0, pointofskills = 0, playerlifevalue = 10, playeraggressivity = 1, headarmorvalue = 0, bodyarmorvalue = 0, legarmorvalue = 0;cout << "已抹掉!" << endl;}system("pause");system("cls");continue;}else if (in(instructions, "帮助")){cout << "一.关键词" << endl;cout << "1.向下、向左、向右:下、左、右" << endl;cout << "2.去某个星球:去(哪里,星球分别有地球、月球、火星、泰坦星、金银星,此处按危险程度排序,在越危险的地方遇到金币,金币将会更多)" << endl;cout << "3.抹掉存档:抹掉" << endl;cout << "4.确认:是、好、要t取消:其它短语均可" << endl;cout << "5.帮助:帮助" << endl;cout << "6.输入无关内容,将跳过" << endl;cout << "二.关于挖矿" << endl;cout << "1.在第0米处只能往下挖" << endl;cout << "三.其它" << endl;cout << "1.游戏将自动保存!" << endl;cout << "如有游戏bug或其它问题,请加QQ:3585914757" << endl;}system("pause");system("cls");save();}}

代码比较乱,多半会有bug,我很有自知之明吧!可以加我QQ:3585914757。

好了,再见!

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。