跳到正文

休闲·娱乐

The Backrooms 后室·无限 游戏代码

xmytommy约 48 分钟
原文

这是 2026年2月13日 存档的第 1 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

发布
2026年2月13日
收录
2026年2月13日
更新
2026年11月12日
篇幅
约 48 分钟

版本

  1. v4当前
  2. v3
  3. v2
  4. v1
C++
#include<bits/stdc++.h>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>
using namespace std;
int level = 0, san = 120, food = 120, hp = 120, buff = 0, sbuff[5], tili = 120;
int wuping = 0, xrs = 0, jjyz = 0, hy = 0, hjkl = 0, gzlr = 0, zsq = 0;
int st = 0, sjcs, sxz, xd, yglgy = 0, man = 0, bbrl = 20, ynmht, rhmht, hf = 0, jj = 0; 
int shiti[100], wuzi[101], sdt, dl, dc, sqdy, bsxh; 
vector <int > swuping; 
//新层级 物品发现地点 分界线 层级名称 实体多少 
//新物品 物品简介 背包物品名称  使用  丢弃
//buff 显示buff  buff效用 

void anjian(){
	while(5) for(int i=0;i<=200;i++)
	if(GetAsyncKeyState(i)&0x8000) cout<<i<<' ';
}
void cls() {
    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
    if (hStdOut == INVALID_HANDLE_VALUE) return;

    CONSOLE_SCREEN_BUFFER_INFO csbi;
    if (!GetConsoleScreenBufferInfo(hStdOut, &csbi)) return;

    DWORD cellCount = csbi.dwSize.X * csbi.dwSize.Y;
    COORD homeCoords = {0, 0};
    DWORD count;

    // 用空格填充整个缓冲区
    FillConsoleOutputCharacter(hStdOut, ' ', cellCount, homeCoords, &count);
    // 将光标重置到左上角
    SetConsoleCursorPosition(hStdOut, homeCoords);
}
void Color(int a)
{
    if(a == 0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
    if(a == 1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
    if(a == 2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
    if(a == 3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
    if(a == 4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
    if(a == 5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
    if(a == 6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
	if(a == 7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY);
	if(a == 8) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
	if(a == 9) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_BLUE);
	if(a == 10) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN);
	if(a == 11) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
}
//  0    1    2  3   4   5   6    7     8      9     10     11 
// 白 较青蓝 绿 紫 大红 青 淡黄 深灰 较深红 较深蓝 较棕黄 浅灰 
void ksfm(){
	Color(0);
	cout << "" << endl;
	cout << "" << endl;
	cout << "" << endl;
	cout << "" << endl;
	cout << "       ■■■■■| ■|     ■■■■■|" << endl;
	cout << "         ■| ̄ ■|     ■ ̄ ̄" << endl;
	cout << "         ■|   ■■■■■| ■■■■■|" << endl;
	cout << "         ■|   ■| ̄■| ■| ̄ ̄" << endl;
	cout << "         ■|   ■|  ■| ■|" << endl;
	cout << "         ■|   ■|  ■| ■■■■■|" << endl;
	cout << "          ̄    ̄   ̄  ̄ ̄ ̄" << endl;
	Sleep(800);
	system("cls");
	int fma[6]={0, 10, 11, 7}, fmb[6]={0, 0, 0, 11, 7}, fmc[6]={0, 10, 11, 7};
	for (int i = 1; i <= 4; i ++){
		cout << "" << endl;
		cout << "" << endl;
		cout << "" << endl;
		cout << "" << endl;
		cout << "" << endl;
		if (i < 3){
			Color(fma[i]);
			cout << "       __  _  __,  .  _  _  _      _." << endl;
		}
		else cout << endl;
		Color(fmb[i]);
		cout << "       |_)/_\\/  |_/  |_)| || |/\\/\\(_" << endl;
		cout << "       | )| |\\  | \\  | \\| || ||  |  )" << endl;
		if (i < 3){
			Color(fmc[i]);
			cout << "        ̄ ̄  ̄ ̄ ̄ ̄   ̄  ̄  ̄ ̄ ̄  ̄" << endl;
		}
		sjcs ++;
		if (i == 1) Sleep(1000);
		else Sleep(100);
		system("cls");
	}
	Color(0);
	system("cls");
	Sleep(1500);
}
void guanyu(){
	cls();
	Color(11);
	cout << endl;
	cout << "     The backrooms" << endl;
	cout << "  如果你不小心,在错误的地方从现实中脱离,你就会来到后室,那里除了潮湿的旧地";
	cout << "  毯的臭味,令人发疯的单调黄色,永不停歇的日光灯最大功率的嗡鸣噪音,以及被随";
	cout << "  机分割成空房间的约六亿平方英里的区域以外什么都没有。如果你听到有东西在附近";
	cout << "                   徘徊,那你只能静待死亡了。" << endl << endl;
	cout << "     什么是后室" << endl;
	cout << "  欢迎来到后室,一个脱离于我们正常的现实世界的地方。你所目前所处的地方被称为Level 0。这是一般";
	cout << "  情况下像你这样不小心脱离了现实,或者说,“卡出了现实世界”的人来到后室的第一站。后室就是一个";
	cout << "  由不同空间,我们一般称之为“楼层”,所组成的迷宫,每个楼层都有它自己奇怪的特性,并以一种诡异";
	cout << "  而复杂的方式连接在一起。有些楼层是相对安全的,比如你现在所在的Level 0,和接下来你会来到的";
	cout << "  Level 1,另一些楼层则是危险的,程度各不相同,但几乎每个楼层都会有威胁存在,这里可不如你以前";
	cout << "  所在的现实世界安全,连物理定律都可能被篡改,还有各种奇形怪状的,我们称之为“实体”的后室生物";
	cout << "  存在。在这里需要时时保持警惕,否则一不小心就会没命。" << endl;
	cout << endl;
	cout << "     我应该干什么" << endl;
	cout << "  探索,求生,寻找,并时刻保持警惕?......" << endl;
	cout << "     操作" << endl;
	cout << "  E打开背包  A/D选择物品  空格使用  P丢弃  Q退出" << endl;
	cout << "  M 查看层级信息" << endl; 
	sjcs ++;
	
	while (1){
		if(kbhit()){
			cls();			
			return;
		}
	}
}
void cenjijianjie(){
	cls();
	Color(0);
	cout << endl;
	if (level == 0){
		cout << "  Level 0 前厅 "<< endl; 
		cout << "  生存难度 class 1" << endl;
		cout << "  >> 安全" << endl;
		cout << "  >> 不稳定" << endl;
		cout << "  >> 无实体" << endl;
		cout << "  Level 0是一个广袤无垠的非欧几里得空间,其外表与零售店的仓库相近,并由无数多个房间排列组合而成。单调的黄色墙纸、老旧潮湿的地毯、分散的电线插座、零散排布的荧光灯共同构成了这一楼层的重复景致。此外,Level 0内不存在任何两个完全相同的房间。楼层内的荧光灯会以恒定的频率嗡嗡作响,只是相比于日常所见的荧光灯,Level 0内的荧光灯会发出更响亮、更突兀、更刺耳的声响。由于报告不一且难以核实,Level 0至今仍被认为实体绝迹。迄今,楼层内不存在任何流浪者会面或遭遇实体的正式记录。" << endl; 
	}
	else if (level == 1){
		cout << "  Level 1 宜居区 "<< endl; 
		cout << "  生存难度 class 1" << endl;
		cout << "  >> 安全" << endl;
		cout << "  >> 稳定" << endl;
		cout << "  >> 实体数量极少" << endl;
		cout << "  Level 1是一座仓库,仓库顶部悬挂着荧光灯,其中有着通向楼层各个区域的廊道与楼梯,以及不时出现的叉车等机械设备。地板上都偶然会出现一些杏仁水洼,蒸发后会遇冷形成浓雾,使该层部分区域的能见度降低许多,并且该层级物资较多。该层内存在多种危险因素,其中包含持续数分钟乃至数天的停电。当Level 1停电时,楼层的主区域将完全失去光亮。此时,一切都会陷入黑暗,实体也将肆意孳生并猎杀流浪者。Level 1内实体种类较多,栖息于这一楼层的常见实体有无面人、肢丛、猎犬、黯人与死亡飞蛾,以及两种Level 1的特有实体。" << endl; 
	} 
}
void Say(char *p,int x)
{
    while(1)
    {
        if(*p!=0) printf("%c",*p++);
        else break;
	Sleep(x);
    }
}
void kscd(){
	int kk = 1, k = 1, xz = 1, stou[10]={0, 3, 2, 1, 0};
	while (k){	
		if (GetAsyncKeyState(38)&0x8000) xz = 1;
		if (GetAsyncKeyState(40)&0x8000) xz = 2;
		if(kbhit()){
			char c=_getch();
			if(c==' ') {
				if (xz == 1) guanyu();
				else return ;
			}
		}
		cout << endl;
		cout << endl;
		Color(11);
		cout << "后室之中·无限" << endl;
		cout << endl;
		cout << "  ";
		Color(7);
		cout << "■■";
		Color(11);
		cout << "■■";
		Color(10);
		cout << "■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■";
		Color(11);
		cout << "■■";
		Color(7);
		cout << "■■"  << endl;
		
		
		int tou = stou[k], jiange = 0;
		cout << "  ";
		Color(7);
		cout << "==";
		Color(11);
		cout << "==";
		for (int i = 1; i <= 30; i ++){
			if (tou){
				tou --;
				Color(10);
				cout << "=";
			}
			else if (jiange){
				jiange --;
				Color(10);
				cout << "=";
			}
			else {
				jiange = 3;
				Color(0);
				cout << "=";
			}
		}
		Color(11);
		cout << "==";
		Color(7);
		cout << "==";
		
		
		int bian = rand() % 100;
		if (bian % 24 == 0){
			cout << endl;
			Color(8);
			cout << "           @" << endl;
			Color(7);
			cout << "          `■" << endl;
			cout << "          |#" << endl;
			cout << "           }" << endl;
			cout << "           [." << endl;
		}
		else {
		cout << endl << endl << endl;
		Color(0);
		cout << "           O" << endl;
		Color(6);
		cout << "           ";
		Color(6);
		if (kk % 3 == 0) cout << "/";
		else if (kk % 3 == 1)cout << "|";
		else cout << "\\" ;
		Color(6);
		cout << " " << endl;
		if (kk % 3 == 0){
			Color(7);
			cout << "          / ";
			Color(11);
			cout << "\\" << endl;
		}
		else if (kk % 3 == 1){
			Color(11);
			cout << "          / ";
			Color(7);
			cout << "\\" << endl;
		}
		else {
			Color(11);
			cout << "           |" << endl;
		}
		}
		
		
		cout << "  "; 
		Color(7);
		cout << "■■";
		Color(11);
		cout << "■■";
		Color(10);
		cout << "■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■";
		Color(11);
		cout << "■■";
		Color(7);
		cout << "■■"  << endl;
		
		
		if (xz == 1) Color(11);
		else Color(7);
		cout << "                  关于" << endl;
		if (xz == 2) Color(11);
		else Color(7);
		cout << "                  探索" << endl;
		
		if(kbhit()){
			char c=_getch();
			if(c==' ') {
				if (xz == 1) guanyu();
				else return ;
			}
		}
		if(GetAsyncKeyState(38)&0x8000) xz = 1;
		if(GetAsyncKeyState(40)&0x8000) xz = 2;
		
		k ++;
		kk ++;
		if (k == 5) k = 1; 
		Sleep(500);
		cls();
	}
	
}
void cengji(){
	Color(0);
	if (level == 0) cout << "Level 0     -- 前厅";
	else if (level == 1) cout << "Level 1     -- 宜居区";
	 
}
void fenjie2(){
	if (level == 0){
		for (int i = 0; i < 30; i ++){
			Color(10);
			cout <<"■";
		}
	}
	else if (level == 1){
		for (int i = 0; i < 30; i ++){
			Color(7);
			cout <<"■";
		}
	}
}
void fenjie1(){
	if (level == 0){
		fenjie2();
		cout << endl;
		for (int i = 0; i < 30; i ++){
			if (i % 6 <= 2){
				Color(10);
				cout << "■";
			}
			else {
				Color(0);
				cout << "=";
			}
		}
	}
	else if (level == 1){
		fenjie2();
		cout << endl;
		for (int i = 0; i < 30; i ++){
			if (i % 8 <= 3){
				Color(7);
				cout << "▓";
			}
			else {
				Color(0);
				cout << "_";
			}
		}
	}
}
void zhuangtai(){
	if (level == 0){
		Color(10);
		cout << "[] ";
	}
}
void Buff(){
	if (bsxh > 0) {
		Color(7);
		cout << "悲尸循环" ; 
	}
	else if (hf > 0){
		Color(2);
		cout << "恢复" ; 
	}
	else if (jj > 0){
		Color(9);
		cout << "安静 ";
	}
}
void wpjj(int x){
	Color(0);
	if (x == 1){
		cout << "杏仁水" << endl;
		cout << "food+10 san+15 hp+5 体力+5";
	}
	else if (x == 2){
		cout << "罐装龙肉" << endl;
		cout << "food+25 hp+5 体力+5";
	} 
	else if (x == 3){
		cout << "皇家口粮" << endl;
		cout << "珍贵的食物 food+35 san-5 hp+10";
	} 
	else if (x == 4){
		cout << "火盐" << endl;
		cout << "投掷 击退!";
	} 
	else if (x == 5){
		cout << "寂静液汁" << endl;
		cout << "使用后处于安静状态中,不易被发现";
	} 
	else if (x == 6){
		cout << "滋水枪" << endl;
		cout << "加入杏仁水,发射!";
	} 
	else if (x == 7){
		cout << "亚格鲁格亚果实" << endl;
		cout << "恢复效果 food+5 san+5 hp+5";
	}
	else if (x == 8){
		cout << "油腻棉花糖" << endl;
		cout << "难以下咽,加点杏仁水或许好些";
	}
	else if (x == 9){
		cout << "融化棉花糖" << endl;
		cout << "美味 food+20 san+5 体力+15";
	}
	else if (x == 10){
		cout << "一节电池" << endl;
		cout << "为手电筒提供电量";
	}
}
void sywp(int x){
	wuping --;
	if (x == 1){
		xrs --;
		food += 10;
		san += 15;
		hp += 5;
		tili += 5;
	}
	else if (x == 2){
		gzlr --;
		food += 25;
		hp += 5;
		tili += 5;
	}
	else if (x == 3){
		hjkl --;
		food += 35;
		san -= 5;
		hp += 10;
	}
	else if (x == 5){
		jj += rand() % 6 + 8;
		sbuff[++buff] = 3;
		jjyz --;
	}
	else if (x == 6){
		if (!xrs){
			wuping ++;
			cout << endl;
			cout << "  你没有填装物!";
			Sleep(500);
		}
		else if (sqdy > 0){
			wuping ++;
			cout << endl;
			cout << "  有填装物了!";
			Sleep(500);
		}
		else {
			sqdy += 5;
			xrs --;
		}
	}
	else if (x == 7){
		yglgy --;
		sbuff[++buff] = 2;
		hf += 6 + rand() % 6;
	}
	else if (x == 8) {
		if ( !xrs){
			wuping ++;
			cout << endl;
			cout << "  你没有东西融化它!";
			Sleep(500);
		}
		else {
			xrs --;
			rhmht ++;
			ynmht --;
		}
	}
	else if (x == 9){
		food += 20;
		san += 5;
		tili += 15;
		rhmht --;
	}
	else if (x == 10){
		if (dl == 0){
			dl = 100;
			dc --; 
		}
		else {
			wuping ++;
			cout << endl;
			cout << "  手电筒还有电!";
			Sleep(500);
		}
	}
}
void dqwp(int x){
	man = 0;
	Color(0);
	cout << endl << "丢弃 "; 
	wuping --;
	if (x == 1){
		cout << "一瓶杏仁水" << endl;
		xrs --;
	}
	else if (x == 2){
		cout << "一罐罐装龙肉" << endl;
		gzlr --;
	} 
	else if (x == 3){
		cout << "一盒皇家口粮" << endl;
		hjkl --;
	} 
	else if (x == 4){
		cout << "一块火盐" << endl;
		hy --;
	} 
	else if (x == 5){
		cout << "一瓶寂静液汁" << endl;
		jjyz --;
	} 
	else if (x == 6){
		cout << "一把滋水枪" << endl;
		zsq --;
	} 
	else if (x == 7){
		cout << "一颗亚格鲁格亚果实" << endl;
		yglgy --;
	}
	else if (x == 8){
		cout << "一包油腻棉花糖" << endl;
		ynmht --;
	}
	else if (x == 9){
		cout << "一包融化棉花糖" << endl;
		rhmht --;
	}
	else if (x == 10){
		cout << "电池" << endl;
		dc --;
	} 
}
void beibao(){
	cls();
	sjcs = rand() % sjcs;
	int xz = 0, xzwp, tc = 0;
	if (wuping > 0) xz = 1;
	
	while (1){
		if (wuping <= bbrl) man = 0;
		int wp = 0, zs = 0, xzwp = 0;
		cout << endl;
		Color(0);
		cout << "背包";
		if (man) cout << "已满,请丢弃或使用物品";
		cout << endl; 
		Color(11);
		cout << "------------------------------" << endl;
		if (xrs > 0){
			for (int i = 1; i <= xrs; i ++){
				wp ++;
				if (wp == xz) xzwp = 1, Color(11);
				else Color(7);
				if (zs + 6 > 30){
					zs = 8;
					cout << endl;
				}
				else {
					zs += 8;
				}
				cout << "杏仁水  ";
			}
		}
		if (gzlr > 0){
			for (int i = 1; i <= gzlr; i ++){
				wp ++;
				if (wp == xz) xzwp = 2, Color(11);
				else Color(7);
				if (zs + 8 > 30){
					zs = 10;
					cout << endl;
				}
				else {
					zs += 10;
				}
				cout << "罐装龙肉  ";
			}
		}
		if (hjkl > 0){
			for (int i = 1; i <= hjkl; i ++){
				wp ++;
				if (wp == xz) xzwp = 3, Color(11);
				else Color(7);
				if (zs + 8 > 30){
					zs = 10;
					cout << endl;
				}
				else {
					zs += 10;
				}
				cout << "皇家口粮  ";
			}
		}
		if (hy > 0){
			for (int i = 1; i <= hy; i ++){
				wp ++;
				if (wp == xz) xzwp = 4, Color(11);
				else Color(7);
				if (zs + 4 > 30){
					zs = 6;
					cout << endl;
				}
				else {
					zs += 6;
				}
				cout << "火盐  ";
			}
		}
		if (jjyz > 0)
		for (int i = 1; i <= jjyz; i ++){
				wp ++;
				if (wp == xz) xzwp = 5, Color(11);
				else Color(7);
				if (zs + 8 > 30){
					zs = 10;
					cout << endl;
				}
				else {
					zs += 10;
				}
				cout << "寂静液汁  ";
		}
		if (zsq > 0)
		for (int i = 1; i <= zsq; i ++){
				wp ++;
				if (wp == xz) xzwp = 6, Color(11);
				else Color(7);
				if (zs + 6 > 30){
					zs = 8;
					cout << endl;
				}
				else {
					zs += 8;
				}
				cout << "滋水枪  ";
		}
		if (yglgy > 0)
		for (int i = 1; i <= yglgy; i ++){
				wp ++;
				if (wp == xz) xzwp = 7, Color(11);
				else Color(7);
				if (zs + 14 > 30){
					zs = 16;
					cout << endl;
				}
				else {
					zs += 16;
				}
				cout << "亚格鲁格亚果实  ";
		}
		if (ynmht > 0)
		for (int i = 1; i <= ynmht; i ++){
				wp ++;
				if (wp == xz) xzwp = 8, Color(11);
				else Color(7);
				if (zs + 10 > 30){
					zs = 12;
					cout << endl;
				}
				else {
					zs += 12;
				}
				cout << "油腻棉花糖  ";
		}
		if (rhmht > 0)
		for (int i = 1; i <= rhmht; i ++){
				wp ++;
				if (wp == xz) xzwp = 9, Color(11);
				else Color(7);
				if (zs + 10 > 30){
					zs = 12;
					cout << endl;
				}
				else {
					zs += 12;
				}
				cout << "融化棉花糖  ";
		}
		if (dc > 0)
		for (int i = 1; i <= dc; i ++){
				wp ++;
				if (wp == xz) xzwp = 10, Color(11);
				else Color(7);
				if (zs + 4 > 30){
					zs = 6;
					cout << endl;
				}
				else {
					zs += 6;
				}
				cout << "电池  ";
		}
		cout << endl;
		Color(11), cout << "------------------------------" << endl;
		wpjj(xzwp);
		cout << endl;
		Color(11), cout << "------------------------------" << endl;
		Color(0), cout << "装备 "  << endl;
		if (sdt == 1){
			cout << "手电筒  " ;
			cout << "电量 ";
			if (dl <= 20) Color(4);
			cout << dl << "%" << endl;
		} 
		while (1){
			if(kbhit()){
				char c=_getch();
				if (c == 'a'){
					xz --;
					if (xz < 1) xz = 1;
					break;
				}
				if (c == 'd'){
					xz ++;
					if (xz > wuping) xz = wuping;
					break;
				}
				if (c == 'q' && !man){
					tc = 1;
					break;
				}
				if (c == ' '){
					sywp(xzwp);
					break;
				}
				if (c == 'p'){
					dqwp(xzwp);
					break;
				}
			}
		}
		cls();
		if (tc == 1) break;
	}
	return ;
}
void qhcj(){
	cls();
	cout << endl << endl;
	int yl = level;
	while (yl == level) level = rand() % 2;
	cout << endl;
	Color(0);
	cout << "      你来到了";cengji();
	Sleep(1500);
}
void tsyy(){
	int sj;
	sjcs ++; 
	int k = max((sjcs + 11) % 24, 1);
	for (int i = 1; i <= k; i ++) sj = rand() % 78;
	if (sj <= 14 || sj >= 72) cout << "继续探索这里" << endl;
	else if (sj > 14 && sj <= 31) cout << "向四处走走" << endl;
	else if (sj > 31 && sj <= 56) cout << "碰碰运气,搜寻一番" << endl;
	else cout << "环顾四周,继续探索" << endl;
}
void xxyy(){
	int sj;
	sjcs ++; 
	int k = max((sjcs + 11) % 24, 1);
	for (int i = 1; i <= k; i ++) sj = rand() % 78;
	if (sj <= 14 || sj >= 63) cout << "探索很久了,歇歇吧" << endl;
	else if (sj > 14 && sj <= 31) cout << "休息一会" << endl;
	else cout << "找处安静地休息" << endl;
}
void xzyy(){
	int sj;
	sjcs ++; 
	int k = max((sjcs + 11) % 24, 1);
	for (int i = 1; i <= k; i ++) sj = rand() % 78;
	if (sj <= 14 || sj >= 63) cout << "想办法离开这儿" << endl;
	else if (sj > 14 && sj <= 31) cout << "寻找层级出口" << endl;
	else cout << "尝试离开这里" << endl;
}
void mysh(){
	int sj;
	sjcs ++; 
	int k = max((sjcs + 11) % 24, 1);
	for (int i = 1; i <= k; i ++) sj = rand() % 78;
	if (sj <= 14 || sj >= 63) cout << "  嗯..没有任何收获" << endl;
	else if (sj > 14 && sj <= 31) cout << "  没有任何结果.." << endl;
	else cout << "  空手而回.." << endl;
} 
void ckdf(){
	if (level == 0){
		int sj = rand() % 3;
		if (sj == 0) cout << "一个通风管道口";
		else if (sj == 1) cout << "一面墙";
		else cout << "一扇玻璃门";
	}
	if (level == 1){
		int sj = rand() % 3;
		if (sj == 0) cout << "一扇门";
		else if (sj == 1) cout << "一段阶梯";
		else cout << "一面带有排水口的墙体";
	} 
}
int xzcksh(){
	cout << endl;
	Color(0);
	int sj = rand() % 100, zd = 0;
	if (sj % 12 == 0 ) zd = 1;
	if (zd == 1){
		cout << "你发现了"; ckdf(); cout << endl;
		return 1;
	}
	else {
		int sj;
		sjcs ++; 
		int k = max((sjcs + 11) % 24, 1);
		for (int i = 1; i <= k; i ++) sj = rand() % 78;
		if (sj <= 34 || sj >= 63) cout << "  好吧,这很难." << endl;
		else cout << "  什么都没发现" << endl;
		return 0;
	}
}
void fxdf(){
	if (level == 0){
		int k = rand() % 2;
		if (k == 0) cout << "地板上";
		else cout << "墙角边";
	} 
	if (level == 1){
		int k = rand() % 4;
		if (k == 0) cout << "板条箱里";
		else if (k == 1) cout << "地板上";
		else if (k == 2) cout << "墙角";
		else cout << "柱子边" ; 
	} 
}
void ysh(){
	int sj;
	sjcs ++; 
	int k = max((sjcs + 11) % 24, 1);
	Color(0);
	wuping ++;
	cout << "你在";
	fxdf();
	cout << "发现了  ";
	for (int i = 1; i <= k; i ++) sj = rand() % 790;
	if (sj >= 130 && sj <= 133 || sj >= 501 && sj <= 510 ||
	 sj >= 671 && sj <=678) {
		cout << "一把滋水枪" << endl;
		zsq ++;
	}
	else if (sj >= 664 && sj <= 677 || sj >= 232 && sj <= 243 || 
	sj == 279 || sj == 378){
		cout << "一颗亚格鲁格亚果" << endl;
		yglgy ++;
	}
	else if (sj >= 74 && sj <= 88 || sj >= 491 && sj <= 512 ||
	 sj >= 98 && sj <= 112 || sj == 11){
		cout << "一小块火盐" << endl;
		hy ++;
	}
	else if (sj >= 700 && sj <= 703 || sj >= 410 && sj <= 423 || 
	sj >= 33 && sj <= 35 || sj >= 632 && sj <= 635){
		cout << "一包油腻棉花糖" << endl;
		ynmht ++;
	}
	else if (sj >= 3 && sj <= 11 || sj >= 704 && sj <= 719 || 
	sj >= 383 && sj <= 395 || sj >= 24 && sj <= 35 || 
	sj >= 552 && sj <= 559 || sj >= 217 && sj <= 222){
		cout << "一罐罐装龙肉" << endl;
		gzlr ++;
	}
	else if (sj >= 179 && sj <= 187 || sj >= 512 && sj <= 522 || 
	sj >= 441 && sj <= 445){
		cout << "一瓶寂静液汁" << endl;
		jjyz ++;
	}
	else if (sj >= 189 && sj <= 197 || sj >= 371 && sj <= 377 || 
	sj >= 67 && sj <= 73){
		cout << "一盒皇家口粮" << endl;
		hjkl ++;
	}
	else if (( sj >= 720 && sj <= 734 || sj >= 378 && sj <= 391 || 
	sj >= 201 && sj <= 217)){
		if (sdt == 0) cout << "一个手电筒" << endl, sdt = 1, dl = max(rand() % 101, 20);
		else cout << "一节电池" << endl, dc ++; 
	}
	else {
		cout << "一瓶杏仁水" << endl;
		xrs ++;
	}
}
int tssh(){
	int sj, hj = 0;
	sj = rand() % 910;
	if ((sj >= 656 && sj <=664) || (sj >= 321 && sj <=332) ||
	 (sj >= 744 && sj <= 751) || (sj >= 801 && sj <= 810) ||
	  (sj >= 431 && sj <=448) || (sj >= 711 && sj <= 720) ||
	   (sj >= 98 && sj <=107) || (sj >= 843 && sj <=847) || 
	   (sj >= 11 && sj <=25) || (sj >= 42 && sj <= 78) ||
	    (sj >= 187 && sj <= 193) || (sj >= 340 && sj <= 373) ||
		 (sj >= 555 && sj <= 569) || (sj >= 799 && sj <= 817) ||
		  (sj >= 899 && sj <= 909) || (sj >= 600 && sj <= 616) ||
		   (sj >= 212 && sj <= 218) ) hj = 1;
		   
	if (sdt && dl > 0 && (sj >= 665 && sj <= 708)) hj = 1;
	
	if (wuzi[level] >= 1 && (sj >= 220 && sj <= 227 ||
	 sj >= 505 && sj <= 513 || sj == 465 )) hj = 1; 
	 
	if (wuzi[level] >= 2 && (sj >= 232 && sj <=243 || 
	sj >= 518 && sj <= 521 || sj >= 332 && sj <= 334)) hj = 1;
	return hj;
}
void sw(int x){
	cls(); 
	cout << endl << endl;
	Color(4);
	cout << "           YOU DEAD" << endl;
	cout << endl;
	cout << "           reason ";
	if (x == 1){
		Color(7);
		cout << "悲尸循环";
	}
	Sleep(1800);
	exit(0);
}
int main(){
	srand((unsigned)time(NULL));
	CONSOLE_CURSOR_INFO cursor_info={1,0}; 
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
    //anjian();
	ksfm();
	kscd();
	cls();
	xd = 1;
	shiti[1] = 1;
	wuzi[1] = 2;
	while (1){
		cls();
		
		
		
		if (sdt) dl = max(0, dl - 1);
		sjcs ++; 
		
		if (food == 0) hp -= rand() % 3;
		if (!xd) food -= rand() % 2, san -= rand() % 3, san += rand() % 2, tili -= rand() % 2, tili += rand() % 2;
		if (hf){
			hf --;
			hp += rand() % 3;
			if (hf == 0) buff --;
		}
		if (jj){
			jj --;
			if (jj == 0) buff --;
		}
		if (bsxh) san -= rand() % 2, bsxh --;
		if (1000 - bsxh >= 16 && bsxh > 0){
			sw(1);
		}
		if (san <= 30 && !bsxh){
			int sj = rand() % 100;
			if(sj % 12 == 0 || (san <= 20 && sj % 9 == 0)){
				bsxh = 1000;
				buff ++;
			}
		}
		else if (san > 40 && bsxh > 0){
			int sj = rand() % 100;
			if(sj % 12 == 0 || (san <= 20 && sj % 9 == 0)){
				buff --;
				bsxh = 0;
			}
		}
		
		tili = min(tili, 120);
		tili = max(tili, 0);
		hp = min(hp, 120);
		hp = max(hp, 0);
		food = min(food, 120);
		food = max(food, 0);
		san = min(san, 120);
		san = max(san, 0);
		if (food == 0) hp -= rand() % 3;
		xd = 0;
		
		cout << endl;
		cout << "   ";
		cengji();
		cout << endl;
		fenjie1();
		cout << endl;//层级及分界 
		
		zhuangtai();
		Color(0);
		cout << "HP ";
		if (hp > 20) Color(0);
		else Color(4);
		cout << hp << "   ";
		if (hp < 100) cout << " ";
		if (hp < 10) cout << " ";
		
		Color(0);
		cout << "FOOD ";
		if (food > 20) Color(0);
		else Color(4);
		cout << food << "   ";
		if (food < 100) cout << " ";
		if (food < 10) cout << " ";
		
		Color(0);
		cout << "SAN ";
		if (san > 20) Color(0);
		else Color(4);
		cout << san << " ";
		if (san < 100) cout << " ";
		if (san < 10) cout << " ";//基础数值 
		
		cout << endl;
		fenjie2();
		cout << endl;//分界 
		
		Color(0);
		cout << "BUFF ";
		if (buff == 0) cout << "--";
		else {
			Buff();
		}//BUFF 
		cout << endl;
		Color(0), cout << "体力  " << tili;
		
		cout << endl;
		fenjie2();
		cout << endl;//分界 
		
		if (!st){
			Color(0);
			cout << "我可以.." << endl;
			cout << " ○  1 ";
			tsyy();
			cout << " ○  2 ";
			xxyy();
			cout << " ○  3 ";
			xzyy(); 
		}
		
		long long xhcs = 0;
		while(++ xhcs < 50000){
			if(kbhit()){
				char c=_getch();
				if(c=='e'){
					beibao();
					break;
				}
				if(c=='1' && food && tili) {
					cout << endl;
					Color(11);
					cout << "   搜寻中";
					Say("...", rand() % 600 + 400);
					cout << endl;
					tili -= rand() % 6;
					food -= rand() % 7;
					san -= rand() % 6;
					hp -= rand() % 2;
					xd = 1;
					int sh = tssh();
					if (sh == 0){
						mysh();
						Sleep(500);
					}
					else{
						ysh();
						Sleep(600);
						if (wuping > bbrl) {
							man = 1;
							beibao();
						}
					}
					break;
				}
				if(c=='2') {
					hp += rand() % 2;
					san -= rand() % 5;
					san += rand() % 7;
					tili += rand() % 17;
					food -= rand() % 5;
					xd = 1;
					Color(11);
					cout << "   休息中";
					Say("...", rand() % 600 + 500);
					break;
				}
				if(c=='3' && tili && food){
					tili -= rand() % 6;
					food -= rand() % 6;
					san -= rand() % 6;
					hp -= rand() % 2;
					xd = 1;
					Color(11);
					cout << "   寻找中";
					Say("...", rand() % 600 + 400);
					cout << endl;
					if (xzcksh()){
						cout << "  是否切换层级." << endl;
						Color(0);
						cout << "  1  是   ";
						Color(0);
						cout << "2  否";
						while (1){
							if(kbhit()){
								char c=_getch();
								if (c == '2') break;
								if (c == '1'){
									qhcj();
									break;
								}
							}
						}
					}
					else {
						Sleep(800);
					}
					break;
				}
				if(c=='m'){
					cenjijianjie();
						cout << endl;
						Color(7);
						cout << "      空格以退出";
					while (1){
						if (kbhit()){
							char c=_getch();
							if (c == ' ') break;
						}
					}
					cls();
					break;
				} 
			}
		}//操作 
	}
	
	return 0;
}
/*
if(kbhit()){
	char c=_getch();
	if(c==' ') cout<<"空格!发射子弹!";
}

 加袋子  实体追逐  层级  层级简介 
*/