1.前言
Hello,我是老六工作室,今天我们搞一个C++纯文字解谜游戏,后面有代码与解析。
感谢支持,点赞鼓励一下,谢谢!
2.代码时间
#include<iostream>
#include<windows.h>
#include<conio.h>
int power=0,light=0;
using namespace std;
int main()
{system("title 一间房屋");cout<<"<一间房屋>"<<endl;cout<<"(1)地板"<<endl;cout<<"(2)电灯"<<endl;cout<<"(3)墙面"<<endl;for(;;){char n1=getch();if(n1=='1'){MessageBox(0,"你捡到了1块电池!","地板",MB_ICONASTERISK);power=1;}if(n1=='2'){if(power==1){MessageBox(0,"你点亮了灯!","电灯",MB_ICONASTERISK);light=1;}else MessageBox(0,"你没有电池,无法开灯!","电灯",MB_ICONWARNING);}if(n1=='3'){if(light==1)break;else MessageBox(0,"墙上的东西,你看不清!","墙面",MB_ICONWARNING);}}cout<<"你环顾四周...";_sleep(100);system("cls");int key=0,password=0;system("title 一间实验室");cout<<"<一间实验室>"<<endl;cout<<"(1)墙面"<<endl;cout<<"(2)桌子"<<endl;cout<<"(3)柜子"<<endl;for(;;){