失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > C++文字小游戏《异世界1》

C++文字小游戏《异世界1》

时间:2019-10-28 17:14:24

相关推荐

C++文字小游戏《异世界1》

#include<bits/stdc++.h>typedef long long ll;using namespace std;const int maxn = 1e6 + 7;struct person {string name;ll maxhealth;ll health;ll fight;ll qian;ll shoulei;ll yzd;};struct guai {ll maxhealth;ll health;ll fight;};//小怪:{222,222,50}//中等怪:{444,444,70}//大怪:{666,666,90}//Boss:{1000,1000,111}person wo = {"", 130, 130, 30, 0, 0, 0};void play(person g1, guai g, string name, int money) {person me = g1;guai zomb = g;int z = 5;while (1) {if (me.health <= 0 && zomb.health <= 0) {cout << "游戏结束!!!" << endl;cout << "你和" << name << "同归于尽了!" << endl;exit(0);}if (me.health <= 0) {cout << "游戏结束!!!" << endl;cout << "你被 " << name << "杀死了!" << endl;exit(0);}if (zomb.health <= 0) {cout << "你胜利了!!!" << endl;cout << name << "死了!" << endl;cout << "你获得了" << money << "个金币!!!" << endl;wo.qian += money;return ;}cout << "你的血量为:" << me.health << "/" << me.maxhealth << endl;cout << name << "的血量为:" << zomb.health << "/" << zomb.maxhealth << endl;cout << "你的技能: 1.打拳(攻击) 2.圣剑斩(攻击,伤害+5) 3.硫酸拳(1.5倍攻击,虚弱5) 4.自我再生(回复80hp) 5.手雷(伤害为200) 6.超级无敌大炸弹(秒杀)" << endl;int j;cin >> j;if (j == 1) {cout << "你 使用了 打拳 !!!" << endl;zomb.health -= me.fight + 10;} else if (j == 2) {cout << "你 使用了 圣剑斩 !!!" << endl;zomb.health -= me.fight;me.fight += 5;} else if (j == 3) {cout << "你 使用了 硫酸拳 !!!" << endl;zomb.health -= me.fight * 1.5;cout << name << " 虚弱了!!!" << endl;zomb.fight -= 4;} else if (j == 4) {if (z > 0) {cout << "你 使用了 自我再生 !!!" << endl;me.health += 80;z--;} else {cout << " 自我再生 技能 使用失败,自动使用 打拳 !!!" << endl;zomb.health -= me.fight + 10;}} else if (j == 5) {if (wo.shoulei > 0) {cout << "你 使用了 手雷 ,消耗一个 手雷 !!!" << endl;wo.shoulei--;zomb.health -= 200;} else {cout << "你的手雷数量不够!!!" << endl;continue;}} else if (j == 6) {if (wo.yzd > 0) {cout << "你 使用了 超级无敌大炸弹 ,消耗一个 超级无敌大炸弹 !!!" << endl;wo.shoulei--;zomb.health -= zomb.health;} else {cout << "你的超级无敌大炸弹数量不够!!!" << endl;continue;}}else{cout << "没有该技能,将自动使用 打拳!!!" << endl;zomb.health-=me.fight + 10;}cout << name << " 使用了 打击 !!!" << endl;me.health -= zomb.fight;zomb.health += 5;if (me.health > me.maxhealth) {me.health = me.maxhealth;}if (zomb.health > zomb.maxhealth) {zomb.health = zomb.maxhealth;}}}void xunlian() {cout << "你要训练什么方面: 1.防御(50元) 2.攻击(75元) 0.离开" << endl;int x;cin >> x;if (x == 1) {if (wo.qian >= 50) {wo.qian -= 50;wo.maxhealth += 20;wo.health += 20;cout << "训练成功!! 你的血量上升20!!!" << endl;} else {cout << "训练失败!! 你的钱还不够!!!" << endl;}} else {if (wo.qian >= 75) {wo.qian -= 75;wo.fight += 20;cout << "训练成功!! 你的攻击力上升20!!!" << endl;} else {cout << "训练失败!! 你的钱还不够!!!" << endl;}}}void shop() {cout << "你要买什么: 1.手雷(150元) 2.超级无敌大炸弹(300元) 3.穿梭者1号(10000元) 0.离开" << endl;int op;cin >> op;if (op == 1) {if (wo.qian >= 150) {wo.qian -= 150;wo.shoulei++;} else {cout << "购买失败,你太穷了!!!" << endl;}} else if (op == 2) {if (wo.qian >= 300) {wo.qian -= 300;wo.yzd++;} else {cout << "购买失败,你太穷了!!!" << endl;}} else if (op == 3) {if (wo.qian >= 10000) {cout << "你买到了“穿梭者一号”,回到了自己的家,但真的就结束了吗……" << endl;exit(0);} else {cout << "购买失败,你太穷了!!!" << endl;}} else {//break;}}int main() {ios::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);cout << "--------------------欢迎来到 “异世界1” 测试版--------------------" << endl;cout << endl << endl << endl << endl << endl;cout << "你是一个不小心穿越到异世界的旅者,在这个世界有一个战斗岛,你可以在里面和怪物战斗,领取赏金;还有一个训练场,你可以训练你的抗击打力和攻击力;最后还有一个商店,那里会售卖强力的武器和你梦寐以求的穿越器“穿梭者1号”。" << endl;cout << "你做出了一个重大的决定:获得穿越器,离开这里!!!" << endl;cout << "你的名字是:" << endl;cin >> wo.name;//想开启外挂可输入“一拳超人”if (wo.name == "一拳超人") {cout << "沉睡在你体内千年的战斗之魂觉醒了!!!" << endl;wo = {"一拳超人", 999, 999, 99999999999999, 500, 0, 0};}while (1) {cout << "你的血量为:" << wo.health << "/" << wo.maxhealth << endl;cout << "你的攻击力为:" << wo.fight << endl;cout << "你有" << wo.qian << "个金币" << endl;cout << "你有" << wo.shoulei << "个手雷" << endl;cout << "你有" << wo.yzd << "个超级无敌大炸弹" << endl;cout << "要干啥: 1.训练 2.冒险 3.商店" << endl;int num;cin >> num;if (num == 1) {xunlian();} else if (num == 2) {cout << "要挑战啥: 1.僵尸 2.石人 3.坦克尸 4.钢铁巨人" << endl;cout << "僵尸:Hp:222 Att:50" << endl;cout << "石人:Hp:444 Att:70" << endl;cout << "坦克尸: Hp:666 Att:90" << endl;cout << "钢铁巨人: Hp:1000 Att:111"<< endl;cout << "提示: 怪物每攻击你一次就会回复5Hp." << endl;int f;cin >> f;//小怪:{222,222,50}//中等怪:{444,444,70}//大怪:{666,666,90}//Boss:{1000,1000,111}if (f == 1) {play(wo, {222, 222, 50}, "僵尸", 300);} else if (f == 2) {play(wo, {444, 444, 70}, "石人", 550);} else if (f == 3) {play(wo, {666, 666, 90}, "坦克尸", 800);} else if (f == 4) {play(wo, {1000, 1000, 200}, "钢铁巨人", 1000);} else {cout << "没有该怪物,将自动离开。" << endl;continue;}} else if (num == 3) {shop();} else {cout << "该地点不存在!!!" << endl;continue;}}return 0;}

如果觉得《C++文字小游戏《异世界1》》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。