【C++ 游戏】密室逃脱

首先来大张旗鼓的介绍一下:

全网之最:

本游戏为全网第一篇C++语言的密室逃脱类剧情游戏

本游戏为全网第一篇将画面类同等性质转化为文字类的游戏

本游戏为画——文类型游戏的突破口,适合借鉴

哈哈好了不吹了,不过上面的都是真的。

如你们所期待的,『逍遥君』 的下一篇游戏【密室逃脱】于 9/2 日如期发布,感谢读者对我的支持,你们的支持是我前进的动力!

以下是本游戏的通关方法

通关方法(建议实在通不了关再看)

客厅:木门、铁门、铁窗、花盆、储物柜、隔间、墙根、暖气片、油烟机
浴室:回客厅,水龙头,浴缸,窗台
卧室:回客厅,保险柜,箱子,电视机,空调

客厅:木门用钥匙->浴室,铁门用4位密码->卧室,铁窗用小刀+电池+12位密码->逃脱,花盆用水->卡片,储物柜用棒子->钥匙,隔间用卡片->螺丝刀,墙根->说明书+铁片,暖气片用撬棍->水,油烟机擦一次->4位密码,油烟机擦三次->8位密码
浴室:水龙头->锁芯,浴缸用铁片->撬棍,窗台->遥控器
卧室:保险柜用8位密码->棒子,箱子用锁芯->小刀,电视机用遥控器+螺丝刀->前6位密码+遥控器的电池,关闭空调->空调盖上后6位密码

注:前6位密码和后6位密码组成了12位密码。

游戏代码

#include <bits/stdc++.h>
#include <windows.h>
#include <ctime>
using namespace std;
int x, Limit_time, t1;
int living_key, living_knife, living_water, living_stick, compart_card, living_battery, bed_screwdrivers, bath_iron, living_crowbar, bed_lock, bed_machine;//电池、螺丝刀、撬棍、锁芯 
int findliving[100], zhao[100], living_havefound[100], findbath[100], bath_havefound[100], bed_havefound[100], findbed[100];//客厅1,浴室2,卧室3 
int living_ca;
void slowsay(string s) {
	for (int i = 0; i < s.size(); i++) {
		cout << s[i];
		Sleep(30);
	}
}
void HideCursor() {
	CONSOLE_CURSOR_INFO cursor_info = {1, 0};
	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
string Mima = "732986512309";
void sayword_living(int id) {
	system("cls");
	Sleep(20);
	if (id == 2) slowsay("你发现了一扇木门\n\n");
	if (id == 3) slowsay("你发现了一扇铁门\n\n");
	if (id == 4) slowsay("客厅的尽头有一扇窗户,可惜是铁的,你打不开\n\n");
	if (id == 5) slowsay("窗前的花盆吸引了你的注意\n\n");
	if (id == 6) slowsay("直到你走近,你才发现你以为的墙面中含有一扇储物柜\n\n");
	if (id == 7) slowsay("你发现了隐匿在墙上的一个小门,可以推开,里面是一个隔间\n\n");
	if (id == 8) slowsay("墙根的霉点吸引了你的注意\n\n");
	if (id == 9) slowsay("陈旧的暖气片似乎有利用价值?\n\n");
	if (id == 10) slowsay("你发现了一个沾满了油污的油烟机\n\n"); 
	if (id > 10) slowsay("你什么也没找到,再找找吗?\n\n");
	else findliving[id] = 1;
	Sleep(2000);
	system("cls");
}
void sayword_bath(int id) {
	system("cls");
	Sleep(20);
	if (id == 3) slowsay("你发现了一个水龙头\n\n");
	if (id == 4) slowsay("一个大浴缸横跨半个浴室,你不可能看不见\n\n");
	if (id == 5) slowsay("窗台上好像有什么东西?\n\n");
	if (id > 5) slowsay("你什么也没找到,再找找吗?\n\n");
	else findbath[id] = 1;
	Sleep(2000);
	system("cls");
}
void sayword_bed(int id) {
	system("cls");
	Sleep(20);
	if (id == 3) slowsay("你发现了一个保险柜\n\n");
	if (id == 4) slowsay("你发现了一个箱子\n\n");
	if (id == 5) slowsay("你发现了一个没有遥控器的电视机\n\n");
	if (id == 6) slowsay("你发现了一个打开着的空调\n");
	if (id > 6) slowsay("你什么也没找到,再找找吗?\n\n");
	else findbed[id] = 1;
	Sleep(2000);
	system("cls");
}
void Judge() {
	int t2 = time(0);
	slowsay("\n\n即将跳转限时挑战评判界面(等待 10s)\n");
	Sleep(10000);
	system("cls");
	int gone_time = t2 - t1;
	if (gone_time <= 900) {
		system("color A");
		slowsay("您的通关用时为 ");
		printf("%d", gone_time);
		slowsay(",用时限制为 900s,您成功了\n");
		Sleep(2000);
	} else {
		slowsay("您的通关用时为 ");
		printf("%d", gone_time);
		slowsay(",用时限制为 900s,很遗憾,您失败了\n");
		Sleep(2000);
	}
}
signed main() {
	srand(time(NULL));
	HideCursor();
	system("title 密室逃脱");
	slowsay("密室逃脱1.0\n\n创作人:『逍遥君』\n\n创作时间:2024/8/26起\n\n全网第一篇文字类型完整剧情的密室逃脱C++游戏\n\n不经允许,请勿转载,后果自负\n\n游戏即将开始,成功离开密室就算胜利");
	Sleep(3000);
	system("cls");
	slowsay("昏暗的灯光照射着房间,地板上渗出了丝丝血迹\n\n");
	Sleep(500);
	slowsay("你忘记了一切的一切,环顾四周,只发现身处一间破旧的小屋\n\n");
	Sleep(500);
	t1 = time(0);
	if (MessageBox(NULL, "是否开始 900s 极限限时挑战?","限时挑战", MB_YESNO) == IDNO) goto Living;
	if (x == 2) goto Living;
	system("color C");
	slowsay("请记住,本次逃脱时间共 900s,若 900s 后仍未完成逃脱,则挑战失败\n\n");
	Sleep(2000);
	Limit_time = 1; 
	system("color F");
	MessageBox(NULL, "警告:900s已开始计时,请迅速寻找线索并通关游戏","Warning", MB_ICONEXCLAMATION);
	MessageBox(NULL, "提示:由于文字输出需要时间,所以请不要重复过多次相同剧情","Warning", MB_OK);
Living:
	system("cls");
	slowsay("<Living room><客厅>\n\n<1>四处看看?\n");//ok
	if (findliving[2]) slowsay("<2>前往木门\n");//ok
	if (findliving[3]) slowsay("<3>前往铁门\n");//ok
	if (findliving[4]) slowsay("<4>前往铁窗\n");//ok
	if (findliving[5]) slowsay("<5>查看花盆\n");//ok
	if (findliving[6]) slowsay("<6>查看储物柜\n");//ok 
	if (findliving[7]) slowsay("<7>前往隔间\n");//ok
	if (findliving[8]) slowsay("<8>墙根\n");//ok
	if (findliving[9]) slowsay("<9>暖气片\n");//ok
	if (findliving[10]) slowsay("<10>擦拭被油污污染的油烟机\n");//ok
	if (Limit_time == 1) slowsay("<-1>查看当前已过时间\n");
	printf("\n");
	scanf("%d", &x);
	system("cls");
	if (!findliving[x] && x != 1 && x != -1) {
		slowsay("输入无效\n");
		Sleep(2000);
		goto Living;
	}
	if (Limit_time == 1 && x == -1) {
		int t2 = time(0);
		printf("已过 %d 秒,剩余 %d 秒", t2 - t1, 900 - t2 + t1);
		Sleep(2000);
	} else if (x == 1) {
		zhao[1]++;
		int sum = 0;
		for (int i = 2; i <= 10; i++) {
			sum += findliving[i];
		}
		if (sum >= 9) {
			int t = rand() % 3;
			if (t == 0) slowsay("你在客厅四处走动,但没有发现其他的东西\n\n");
			if (t == 1) slowsay("你翻遍了每一个角落,但是貌似一切都如瓮中之鳖,被你尽收眼底\n\n");
			if (t == 2) slowsay("似乎你已经找完了所有地方了\n\n");
			Sleep(2000);
		} else if (zhao[1] > 25) {
			for (int i = 2; i <= 10; i++) {
				if (!findliving[i]) {
					findliving[i] = 1;
					sayword_living(i);
					break;
				}
			}
		} else {
			int none = rand() % 5;
			if (none == 0) {
				sayword_living(11);
			} else {
				vector<int> all;
				for (int i = 2; i <= 10; i++) {
					if (!findliving[i]) {
						all.push_back(i);
					}
				}
				int Rand = rand() % all.size();
				sayword_living(all[Rand]);
			}
		}
	} else if (x == 2) {
		if (!living_key) {
			slowsay("你需要一把钥匙\n\n");
			Sleep(2000);
		} else {
			if (!living_havefound[2]) {
				slowsay("你使用你找到的钥匙打开了木门\n\n");
				Sleep(500);
				slowsay("啊...怎么还不是外面啊...\n\n一间浴室...我没眼花吧?...\n\n");
				Sleep(2000);
				living_havefound[2] = 1;
				goto Bath;
			}
			if (living_havefound[2] == 1) {
				slowsay("你进入了浴室\n\n");
				Sleep(2000);
				goto Bath;
			}
		}
	} else if (x == 3) {
		if (!living_havefound[3]) {
			slowsay("请输入四位数字密码:");
			int mi;
			cin >> mi;
			if (mi == 1928) {
				slowsay("密码正确\n\n");
				Sleep(2000);
				living_havefound[3] = 1;
				slowsay("你悄悄地推开门,走了进去,里面竟然是一间卧室!\n\n");
				Sleep(2000);
				slowsay("线索真的越来越多了呢...你想。\n\n");
				Sleep(2000);
				goto Bed;
			} else {
				system("color C");
				slowsay("密码错误\n\n");
				Sleep(2000);
				system("color F");
			}
		}
		if (living_havefound[3]) {
			slowsay("你进入了卧室\n\n");
			Sleep(2000);
			goto Bed;
		}
	} else if (x == 4) {
		if (!living_knife) {
			slowsay("铁窗十分坚固,你暂且无法将它打开\n\n");
			Sleep(2000);
		} else {
			if (living_havefound[4] == 0) {
				slowsay("经过你的尝试,你用你的小刀将铁窗划开了一个大口\n\n");
				living_havefound[4] = 1;
				Sleep(2000);
			}
			if (living_havefound[4] == 1 && !living_battery) {
				slowsay("里面是一架机器,但是电池被偷走了,你暂时无法将它启动\n\n");
				Sleep(2000);
				slowsay("我是不是漏了点什么?你对自己说。\n\n");
				Sleep(2000);
			} else if (living_havefound[4] == 1 && living_battery) {
				slowsay("你用电池激活了其中的机器,屏幕缓缓亮起,露出了输入密码的空格\n\n");
				Sleep(2000);
				slowsay("请输入 12 位密码:");
				living_havefound[4] = 2;
				string mima;
				cin >> mima;
				if (mima != Mima) {
					system("color C");
					slowsay("密码错误\n\n");
					Sleep(2000);
					system("color F");
				} else {
					slowsay("随着你的输入,机器缓缓打开,露出了外面的世界\n\n一栋栋废弃的高楼林立在各处,毫无气息可言\n\n满是硝烟的战场浮现在了你的眼前,你惊讶地看着眼前这一切,不相信这是真正的世界\n\n战争肆虐,人民流离失所,无家可归\n\n“或许这里才是最好的归宿呢”你想\n\n随后你看了看身后,却发现不知什么时候对面的墙上露出了一行血液写的字:\n\n“DOOMSDAY CAGE”似乎还是新写上去的,血液正在亿点点地留下\n\n你突然明白了一切,一百年前外面开始爆发战乱\n\n所有这个国家的幸存者都被冷冻而安放到各个不为人知的密室中了\n\n而过了一百年就会从“末日笼”中苏醒,自己寻找生路\n\n你回忆起了一切,不禁唏嘘感叹\n\n你从窗户探出头,看向了四周的房间\n\n一个个不同形状的末日笼中,装着一个个相同的你\n\nThe End............\n\n");
					system("color C");
					if (Limit_time == 1) {
						Judge();
					} 
					return 0;
				}
			} else if (living_havefound[4] == 2) {
				slowsay("请输入 12 位密码:");
				string mima;
				cin >> mima;
				if (mima != Mima) {
					system("color C");
					slowsay("密码错误\n\n");
					Sleep(2000);
					system("color F");
				} else {
					slowsay("随着你的输入,机器缓缓打开,露出了外面的世界\n\n一栋栋废弃的高楼林立在各处,毫无气息可言\n\n满是硝烟的战场浮现在了你的眼前,你惊讶地看着眼前这一切,不相信这是真正的世界\n\n战争肆虐,人民流离失所,无家可归\n\n“或许这里才是最好的归宿呢”你想\n\n随后你看了看身后,却发现不知什么时候对面的墙上露出了一行血液写的字:\n\n“DOOMSDAY CAGE”似乎还是新写上去的,血液正在亿点点地留下\n\n你突然明白了一切,一百年前外面开始爆发战乱\n\n所有这个国家的幸存者都被冷冻而安放到各个不为人知的密室中了\n\n而过了一百年就会从“末日笼”中苏醒,自己寻找生路\n\n你回忆起了一切,不禁唏嘘感叹\n\n你从窗户探出头,看向了四周的房间\n\n一个个不同形状的末日笼中,装着一个个相同的你\n\nThe End............\n\n");
					system("color C");
					if (Limit_time == 1) {
						Judge();
					}
					return 0;
				}
			}
		}
	} else if (x == 5) {
		if (!living_water) {
			slowsay("花盆中的花枯萎的不行,泥土也龟裂了几条大口\n\n或许我应该找点水来?你想。\n\n");
			Sleep(2000);
		} else {
			if (!living_havefound[5]) {
				slowsay("你找到了一些水来,将泥土弄湿,一张卡片状的物体显露了出来\n\n");
				living_havefound[5] = 1;
				compart_card = 1;
				Sleep(2000);
			} else {
				slowsay("你已经取走了这里的卡片\n\n");
				Sleep(2000);
			}
		}
	} else if (x == 6) {
		if (!living_havefound[6]) {
			if (!living_stick) {
				slowsay("你慢慢打开柜门,一个不知是什么的东西突然扑到了你的头上\n\n啊......\n\n什么?&@#>$@#$>...怎么会这样\n\n这一切的一切\n\n到底是谁在作祟......\n\n......我不知道\n\n...却可以重新来过\n\n......\n\n");
				Sleep(2000);
				slowsay("几分钟后,你又醒了过来,依然在客厅\n\n");
				Sleep(2000);
			} else {
				slowsay("你慢慢打开柜门,一个不知是什么的东西突然扑到了你的头上\n\n你立刻用手中的棍子将它打了出去\n\n");
				Sleep(2000);
				slowsay("在它的身体里,你发现了一串钥匙\n\n");
				Sleep(2000);
				living_key = 1;
				living_havefound[6] = 1;
			}
		} else {
			slowsay("里面什么也没有了\n\n");
			Sleep(2000);
		}
	} else if (x == 7) {
		if (!compart_card) {
			slowsay("门口有一个刷卡器,但是你没有卡\n\n倒是有了卡再来啊...\n\n");
			Sleep(2000);
		} else {
			if (!living_havefound[7]) {
				slowsay("隔间很大,但是能用的东西却只有一个螺丝刀\n\n");
				bed_screwdrivers = 1;
				Sleep(2000);
				living_havefound[7] = 1;
			} else {
				slowsay("里面都被你翻了个底朝天,但还是找不到其他东西了\n\n");
				Sleep(2000);
			}
		}
	} else if (x == 8) {
		if (!living_havefound[8]) {
			slowsay("墙角有一个说明书样的东西,上面的墨水已经残缺,隐约能看出下面的字迹:\n\n战.....Y@#?争始..........1$#@Msd\n铁...23/342#$(%$窗)出.....密*@#($())0..\n\n");
			Sleep(2000);
			slowsay("你什么也没看懂\n\n但在一个不起眼的角落里,你发现了一块铁片\n\n");
			Sleep(2000);
			bath_iron = 1;
			living_havefound[8] = 1;
		} else {
			slowsay("除了一团脏灰,你什么也没找到\n\n");
			Sleep(2000);
		}
	} else if (x == 9) {
		if (!living_crowbar) {
			slowsay("你没有趁手的工具,暂时对它无可奈何\n\n");
			Sleep(2000);
		} else {
			if (!living_havefound[9]) {
				slowsay("你用撬棍将其撬开,接到了最后的一些水\n\n");
				Sleep(2000);
				living_water = 1;
				living_havefound[9] = 1;
			} else {
				slowsay("里面已经没有水了\n\n");
				Sleep(2000);
			}
		}
	} else if (x == 10) {
		if (living_ca > 3) {
			slowsay("这里擦得十分亮了\n\n");
			Sleep(2000);
		} else if (living_ca == 3) {
			slowsay("你轻轻擦拭油烟机,却有了意外的发现\n\n在1928后面还有一串小的八位数字\n\n20240826\n\n");
			Sleep(2000);
			slowsay("你默默地记在了心里(密码无法二次看到,请一定记好!)\n\n");
			Sleep(2000);
		} else if (living_ca == 1 || living_ca == 2) {
			slowsay("你又擦了擦,暂时没有新的发现\n\n");
			Sleep(2000);
		} else {
			slowsay("你轻轻擦了擦油烟机,一串数字显露了出来:1928\n\n");
			Sleep(2000);
			slowsay("你轻易地记了下来(请记下来)\n\n");
			Sleep(2000);
		}
		living_ca++; 
	} else {
		printf("输入错误\n");
		Sleep(2000);
	}
	goto Living;
Bath:
	system("cls");
	slowsay("<Bath room><浴室>\n\n<1>四处看看?\n<2>回到客厅\n");//ok//ok
	if (findbath[3]) slowsay("<3>前往水龙头\n");//ok
	if (findbath[4]) slowsay("<4>前往浴缸\n");//ok
	if (findbath[5]) slowsay("<5>查看窗台\n");//ok
	if (Limit_time == 1) slowsay("<-1>查看当前已过时间\n");
	printf("\n");
	scanf("%d", &x);
	system("cls");
	if (!findbath[x] && x != 1 && x != 2 && x != -1) {
		slowsay("输入无效\n");
		Sleep(2000);
		goto Bath;
	}
	if (Limit_time == 1 && x == -1) {
		int t2 = time(0);
		printf("已过 %d 秒,剩余 %d 秒", t2 - t1, 900 - t2 + t1);
		Sleep(2000);
	} else if (x == 1) {
		zhao[2]++;
		int sum = 0;
		for (int i = 3; i <= 5; i++) {
			sum += findbath[i];
		}
		if (sum >= 3) {
			int t = rand() % 3;
			if (t == 0) slowsay("你在浴室四处走动,但没有发现其他的东西\n\n");
			if (t == 1) slowsay("你翻遍了每一个角落,但是貌似一切都如瓮中之鳖,被你尽收眼底\n\n");
			if (t == 2) slowsay("似乎你已经找完了所有地方了\n\n");
			Sleep(2000);
		} else if (zhao[2] > 10) {
			for (int i = 3; i <= 5; i++) {
				if (!findbath[i]) {
					findbath[i] = 1;
					sayword_bath(i);
					break;
				}
			}
		} else {
			int none = rand() % 5;
			if (none == 0) {
				sayword_bath(11);
			} else {
				vector<int> all;
				for (int i = 3; i <= 5; i++) {
					if (!findbath[i]) {
						all.push_back(i);
					}
				}
				int Rand = rand() % all.size();
				sayword_bath(all[Rand]);
			}
		}
	} else if (x == 2) {
		slowsay("你回到了客厅\n\n");
		Sleep(2000);
		goto Living;
	} else if (x == 3) {
		if (!bath_havefound[3]) {
			slowsay("水龙头是坏的,但你在水龙头的内部发现了一个锁芯\n\n");
			Sleep(2000);
			bed_lock = 1;
			bath_havefound[3] = 1;
		} else {
			slowsay("这里没有什么了\n\n");
			Sleep(2000);
		}
	} else if (x == 4) {
		if (!bath_iron) {
			slowsay("浴缸中间有一个很小的裂缝,你需要一个细小的东西来撬开它\n\n");
			Sleep(2000);
		} else {
			if (!bath_havefound[4]) {
				slowsay("你用铁片撬开了浴缸,里面藏有一个撬棍\n\n");
				Sleep(2000);
				living_crowbar = 1;
				bath_havefound[4] = 1;
			} else {
				slowsay("你已经撬开过浴缸了\n\n");
				Sleep(2000);
			}
		}
	} else if (x == 5) {
		if (!bath_havefound[5]) {
			slowsay("窗台上有一个遥控器,你拿了起来\n\n");
			Sleep(2000);
			bed_machine = 1;
			bath_havefound[5] = 1; 
		} else {
			slowsay("窗台上什么都没有了\n\n");
			Sleep(2000);
		}
	} else {
		slowsay("输入错误\n");
		Sleep(2000);
	}
	goto Bath;
Bed:
	system("cls");
	slowsay("<Bed room><卧室>\n\n<1>四处看看?\n<2>回到客厅\n");//ok//ok
	if (findbed[3]) slowsay("<3>查看保险柜\n");//ok
	if (findbed[4]) slowsay("<4>拿起箱子\n");//ok
	if (findbed[5]) slowsay("<5>前往电视机\n");//ok
	if (findbed[6]) slowsay("<6>前往空调\n");
	if (Limit_time == 1) slowsay("<-1>查看当前已过时间\n");
	printf("\n");
	scanf("%d", &x);
	system("cls");
	if (!findbed[x] && x != 1 && x != 2 && x != -1) {
		slowsay("输入无效\n");
		Sleep(2000);
		goto Bed;
	}
	if (Limit_time == 1 && x == -1) {
		int t2 = time(0);
		printf("已过 %d 秒,剩余 %d 秒", t2 - t1, 900 - t2 + t1);
		Sleep(2000);
	} else if (x == 1) {
		zhao[3]++;
		int sum = 0;
		for (int i = 3; i <= 6; i++) {
			sum += findbed[i];
		}
		if (sum >= 4) {
			int t = rand() % 3;
			if (t == 0) slowsay("你在卧室四处走动,但没有发现其他的东西\n\n");
			if (t == 1) slowsay("你翻遍了每一个角落,但是貌似一切都如瓮中之鳖,被你尽收眼底\n\n");
			if (t == 2) slowsay("似乎你已经找完了所有地方了\n\n");
			Sleep(2000);
		} else if (zhao[3] > 15) {
			for (int i = 3; i <= 6; i++) {
				if (!findbed[i]) {
					findbed[i] = 1;
					sayword_bed(i);
					break;
				}
			}
		} else {
			int none = rand() % 5;
			if (none == 0) {
				sayword_bed(11);
			} else {
				vector<int> all;
				for (int i = 3; i <= 6; i++) {
					if (!findbed[i]) {
						all.push_back(i);
					}
				}
				int Rand = rand() % all.size();
				sayword_bed(all[Rand]);
			}
		}
	} else if (x == 2) {
		slowsay("你回到了客厅\n\n");
		Sleep(2000);
		goto Living;
	} else if (x == 3) {
		if (!bed_havefound[3]) {
			slowsay("请输入保险柜 8 位密码:");
			scanf("%d", &x);
			if (x == 20240826) {
				slowsay("密码正确\n\n");
				Sleep(2000);
				slowsay("你缓缓打开了保险柜,却发现里面只有一个棒子\n\n“这什么破保险柜?”你骂道。\n\n");
				Sleep(2000);
				living_stick = 1;
				bed_havefound[3] = 1;
			} else {
				system("color C"); 
				slowsay("密码错误\n\n");
				Sleep(2000);
				system("color F");
			}
		} else {
			slowsay("你已经取走了保险柜里的东西\n\n");
			Sleep(2000);
		}
	} else if (x == 4) {
		if (!bed_lock) {
			slowsay("箱子上面有个缺了锁芯的锁,你需要一个锁芯\n\n");
			Sleep(2000);
		} else {
			if (!bed_havefound[4]) {
				slowsay("你用锁芯打开了箱子,里面有一个小刀\n\n");
				Sleep(2000);
				living_knife = 1;
				bed_havefound[4] = 1;
			} else {
				slowsay("你已经取走了箱子里的物品\n\n");
				Sleep(2000);
			}
		}
	} else if (x == 5) {
		if (!bed_machine) {
			slowsay("你没有可以打开它的遥控器\n\n");
			Sleep(2000);
		} else {
			if (!bed_havefound[5]) {
				slowsay("你用遥控器打开了电视\n\n电视上显现出 6 位数字:732986\n\n");
				Sleep(2000);
				slowsay("你在心中记下了(请记下)\n\n");
				Sleep(2000);
				bed_havefound[5] = 1;
			} else {
				slowsay("电视机上没有别的东西了\n\n");
				Sleep(2000);
			}
			if (bed_screwdrivers == 1 && !living_battery) {
				slowsay("你用螺丝刀撬开了遥控器,取出了电池\n\n");
				Sleep(2000);
				living_battery = 1;
			}
		}
	} else if (x == 6) {
		if (!bed_havefound[6]) {
			slowsay("你点击了一下【关闭】,空调缓缓关上了\n\n在空调盖上,有 6 位数字:512309\n\n");
			Sleep(2000);
			slowsay("你在心中记下了(请记下)\n\n");
			Sleep(2000);
			bed_havefound[6] = 1;
		} else {
			slowsay("空调已经关上且不可打开了\n\n");
			Sleep(2000);
		}
	} else {
		slowsay("输入错误\n");
		Sleep(2000);
	}
	goto Bed;
	return 0;
}

建议一开始玩的朋友不要选择限时游玩,很难的!!!

提示:全游戏没有需要按回车用来跳过剧情的地方,大多数地方两秒后自动更新剧情。 

感谢粉丝们的资瓷,能不能有个赞呀!!

  • 7
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
创建一个完整的C++密室逃脱游戏涉及到大量的编程工作,包括游戏逻辑、用户界面、场景设计等多个方面。由于这需要深入的知识和篇幅较长,我会提供一个简单的概念性的框架作为起点: ```cpp #include <iostream> #include <string> class Room { public: std::string description; std::string exit; // 添加描述、查看描述等方法 void setDescription(const std::string& desc) { description = desc; } void setExit(const std::string& e) { exit = e; } virtual std::string play() { return "You are in a room with the following description: " + description + ". The exit is at " + exit + "."; } }; // 子类实现特定房间 class EscapeRoom : public Room { private: bool keyFound; public: // 添加钥匙找寻功能 void findKey() { keyFound = true; } // 如果找到钥匙,可以改变play方法的行为 std::string play() override { if (keyFound) { return "With the key, you can now escape through the door."; } else { return super::play(); } } }; int main() { EscapeRoom room; room.setDescription("A locked room with a mysterious object on the table."); room.setExit("north"); std::cout << room.play() << std::endl; // 检查并尝试打开门 if (!room.keyFound) { room.findKey(); // 假设玩家找到了钥匙 } std::cout << room.play() << std::endl; return 0; } ``` 这是一个非常基础的例子,实际游戏中你会需要更复杂的设计,比如事件驱动系统、图形用户界面(如果需要)、谜题解决机制等等。要继续这个项目,你可以学习如何处理用户输入、使用类和对象管理状态、以及构建递归或循环结构以模拟解谜过程。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值