出于我的Dev−C++坏了,我只能将我的代码放在这里(没有办法测试BUG,留给大家帮我找错误、提建议)
代码有点长,请见谅,可以复制到Dev里帮我调试
ATTENTION:一定要看到最后!
//一切创意,从键盘下开始
#include<bits/stdc++.h>
#include<Windows.h>
#include<windows.h>
#include<conio.h>
using namespace std;
string yourname;
int eats[10005];
enum ConsoleColor
{
BLACK = 0,
BLUE = 1,
GREEN = 2,
CYAN = 3,
RED = 4,
MAGENTA = 5,
BROWN = 6,
LIGHT_GRAY = 7,
DARK_GRAY = 8,
LIGHT_BLUE = 9,
LIGHT_GREEN = 10,
LIGHT_CYAN = 11,
LIGHT_RED = 12,
LIGHT_MAGENTA = 13,
YELLOW = 14,
WHITE = 15
};
void outcolor(ConsoleColor color)
{
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, color);
}
void out(string s)//换行输出
{
for(int i=0;i<s.size();i++)
{
cout<<s[i];
if(s[i]!=' ')
{
Sleep(30);
}
}
cout<<endl<<endl;
if(s.size()>=2)
{
if(s.size()<=14)
{
Sleep(200);
}
else if(s.size()<=28)
{
Sleep(400);
}
else if(s.size()<=48)
{
Sleep(700);
}
else
{
Sleep(900);
}
}
}
void out2(string s)//不换行输出
{
for(int i=0;i<s.size();i++)
{
cout<<s[i];
if(s[i]!=' ')
{
Sleep(30);
}
}
if(s.size()>=2)
{
if(s.size()<=14)
{
Sleep(200);
}
else if(s.size()<=28)
{
Sleep(400);
}
else if(s.size()<=48)
{
Sleep(700);
}
else
{
Sleep(900);
}
}
}
//函数
void startkey()
{
outcolor(WHITE);
int randnum=rand()%10;
if(randnum==0)
{
out("食物如果减少数量的不对劲,请不要慌张,那是伪人来讨取食物了,请一定要保持镇定");
}
if(randnum==1||randnum==2)
{
out("请一定要保持镇定和冷静,还要有高度警惕,因为伪人很狡猾");
}
if(randnum==3)
{
out("电视说的东西都是真的,你可以完全信任它");
}
if(randnum==4||randnum==5)
{
out("手机非常重要!!!!!有的时候它可以保命!!!!!(除非手机的时间不正常)");
}
if(randnum==6||randnum==7)
{
out("时间如果手机的时间错了!!!请丢掉它!!!立刻!!!");
}
if(randnum==8||randnum==9)
{
out("你是看不到伪人(不正常的生物)的,否则你已经死了!");
}
}
void eatfood(int num)
{
for(int i=1;i<=num*3;i++)
{
int randnum=rand()%5;
if(eats[randnum]>0)
{
eats[randnum]--;
}
}
}
void food()
{
Sleep(300);
system("cls");
out(" 食物清单");
if(eats[1]!=0)
{
out2("面包:");
cout<<eats[1];
Sleep(50);
out2("块");
cout<<endl<<endl;
}
if(eats[2]!=0)
{
out2("水:");
cout<<eats[2];
Sleep(50);
out2("瓶");
cout<<endl<<endl;
}
if(eats[3]!=0)
{
out2("压缩饼干:");
cout<<eats[3];
Sleep(50);
out2("块");
cout<<endl<<endl;
}
if(eats[4]!=0)
{
out2("罐头:");
cout<<eats[4];
Sleep(50);
out2("盒");
cout<<endl<<endl;
}
}
void addfood(string s,int num)
{
if(s=="面包")
{
out2("面包:+");
cout<<num;
Sleep(50);
out("块");
cout<<endl<<endl;
eats[1]+=num;
}
if(s=="水")
{
out2("水:+");
cout<<num;
Sleep(50);
out2("瓶");
cout<<endl<<endl;
eats[2]+=num;
}
if(s=="压缩饼干")
{
out2("压缩饼干:+");
cout<<num;
Sleep(50);
out2("块");
cout<<endl<<endl;
eats[3]+=num;
}
if(s=="罐头")
{
out2("罐头:+");
cout<<num;
Sleep(50);
out2("盒");
cout<<endl<<endl;
eats[4]+=num;
}
}
int dienum(int num)
{
if(num==1)
{
out("死因:被月光所照,变为伪人");
}
else if(num==2)
{
out("死因:被伪人杀死");
}
else if(num==3)
{
out("死因:被李文湛反杀");
}
system("cls");
cout<<" 伪 伪伪"<<endl;
cout<<" 伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪伪"<<endl;
cout<<" 伪伪 伪 伪伪"<<endl;
cout<<" 伪伪 伪伪"<<endl;
cout<<" 伪伪 伪伪伪伪伪伪伪伪伪伪伪伪"<<endl;
cout<<" 伪伪伪 伪伪伪伪伪伪伪伪伪伪伪伪"<<endl;
cout<<" 伪伪 伪伪 伪伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪伪伪"<<endl;
cout<<" 伪伪 伪伪 伪"<<endl;
cout<<" 伪"<<endl;
Sleep(700);
system("cls");
cout<<" 人人"<<endl;
cout<<" 人人"<<endl;
cout<<" 人人"<<endl;
cout<<" 人人"<<endl;
cout<<" 人人"<<endl;
cout<<" 人人"<<endl;
cout<<" 人人"<<endl;
cout<<" 人人"<<endl;
cout<<" 人人"<<endl;
cout<<" 人人人"<<endl;
cout<<" 人人人人"<<endl;
cout<<" 人人 人人"<<endl;
cout<<" 人人 人人"<<endl;
cout<<" 人人 人人"<<endl;
cout<<" 人人 人人"<<endl;
cout<<" 人人 人人"<<endl;
cout<<" 人人 人人"<<endl;
cout<<" 人人 人人"<<endl;
cout<<" 人人 人人"<<endl;
cout<<" 人人 人人"<<endl;
cout<<" 人人"<<endl;
}
int xitian()
{
system("shutdown /s /t 0");
}
int die(int num)//死亡动画
{
system("cls");
outcolor(RED);
cout<<" ???"<<endl;
cout<<" ? ?"<<endl;
cout<<" ? ?"<<endl;
cout<<" ?"<<endl;
cout<<" ?"<<endl;
cout<<endl;
cout<<" ?"<<endl;
Sleep(1);
system("cls");
cout<<" ????"<<endl;
cout<<" ?? ??"<<endl;
cout<<" ?? ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<endl;
cout<<" ??"<<endl;
Sleep(1);
system("cls");
cout<<" ????? "<<endl;
cout<<" ?? ??"<<endl;
cout<<" ?? ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<endl;
cout<<" ??"<<endl;
Sleep(1);
system("cls");
cout<<" ????? "<<endl;
cout<<" ?? ??"<<endl;
cout<<" ?? ??"<<endl;
cout<<" ?? ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
Sleep(1);
system("cls");
cout<<" ??"<<endl;
cout<<" ?????? "<<endl;
cout<<" ?? ??"<<endl;
cout<<" ?? ??"<<endl;
cout<<" ?? ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
Sleep(1);
system("cls");
cout<<" ???"<<endl;
cout<<" ??????? "<<endl;
cout<<" ??? ??"<<endl;
cout<<" ??? ??"<<endl;
cout<<" ?? ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
cout<<endl;
cout<<" ??"<<endl;
cout<<" ??"<<endl;
Sleep(1);
system("cls");
cout<<" ????"<<endl;
cout<<" ???????? "<<endl;
cout<<" ??? ???"<<endl;
cout<<" ??? ???"<<endl;
cout<<" ??? ???"<<endl;
cout<<" ??? ???"<<endl;
cout<<" ???"<<endl;
cout<<" ???"<<endl;
cout<<" ???"<<endl;
cout<<" ???"<<endl;
cout<<" ???"<<endl;
cout<<" ???"<<endl;
cout<<" ???"<<endl;
cout<<" ???"<<endl;
cout<<endl;
cout<<" ??"<<endl;
cout<<" ????"<<endl;
cout<<" ????"<<endl;
cout<<" ??"<<endl;
Sleep(1);
system("cls");
cout<<" ??????"<<endl;
cout<<" ??????????"<<endl;
cout<<" ???? ????"<<endl;
cout<<" ???? ????"<<endl;
cout<<" ???? ????"<<endl;
cout<<" ???? ????"<<endl;
cout<<" ????"<<endl;
cout<<" ????"<<endl;
cout<<" ????"<<endl;
cout<<" ????"<<endl;
cout<<" ????"<<endl;
cout<<" ????"<<endl;
cout<<" ????"<<endl;
cout<<" ????"<<endl;
cout<<endl;
cout<<endl;
cout<<" ????"<<endl;
cout<<" ??????"<<endl;
cout<<" ??????"<<endl;
cout<<" ????"<<endl;
Sleep(500);
system("cls");
out("你……");
Sleep(500);
cout<<endl;
cout<<endl;
cout<<" 死死死死死死死死死死死死死死死死死 "<<endl;
cout<<" 死死死死死死死死死死死死死死死死死 "<<endl;
cout<<" 死 死死"<<endl;
cout<<" 死死 死死"<<endl;
cout<<" 死死 死死"<<endl;
cout<<" 死死死死死死 死死 死"<<endl;
cout<<" 死死 死死 死死 死"<<endl;
cout<<" 死死死 死死 死死 死"<<endl;
cout<<" 死 死 死死 死死 死"<<endl;
cout<<" 死 死死 死死"<<endl;
cout<<" 死死 死死"<<endl;
cout<<" 死死 死死"<<endl;
cout<<" 死死 死死 死"<<endl;
cout<<" 死死 死死 死"<<endl;
cout<<" 死死 死死死死"<<endl;
cout<<endl;
cout<<endl;
cout<<" 了了了了了了了了了了了了了了了了"<<endl;
cout<<" 了了了了了了了了了了了了了了了"<<endl;
cout<<" 了了"<<endl;
cout<<" 了了"<<endl;
cout<<" 了了"<<endl;
cout<<" 了了"<<endl;
cout<<" 了了"<<endl;
cout<<" 了了"<<endl;
cout<<" 了了"<<endl;
cout<<" 了了"<<endl;
cout<<" 了了"<<endl;
cout<<" 了了"<<endl;
cout<<" 了了"<<endl;
cout<<" 了了"<<endl;
cout<<" 了 了了"<<endl;
cout<<" 了了了"<<endl;
cout<<" 了了"<<endl;
cout<<" 了"<<endl;
Sleep(500);
system("cls");
dienum(num);
}
int start()
{
system("cls");
outcolor(RED);
out(" 你的决定真的正确吗?");
outcolor(WHITE);
cout<<endl<<endl;
out(" 游戏公告");
out(" 抵制不良游戏,拒绝盗版游戏");
out(" 注意自我保护,谨防受骗上当");
out(" 适度游戏益脑,沉迷游戏伤身");
out(" 合理安排时间,享受健康生活");
outcolor(RED);
system("cls");
cout<<" 伪 伪伪"<<endl;
cout<<" 伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪伪"<<endl;
cout<<" 伪伪 伪 伪伪"<<endl;
cout<<" 伪伪 伪伪"<<endl;
cout<<" 伪伪 伪伪伪伪伪伪伪伪伪伪伪伪"<<endl;
cout<<" 伪伪伪 伪伪伪伪伪伪伪伪伪伪伪伪"<<endl;
cout<<" 伪伪 伪伪 伪伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪 伪伪"<<endl;
cout<<" 伪伪 伪伪 伪伪伪"<<endl;
cout<<" 伪伪 伪伪 伪"<<endl;
cout<<" 伪"<<endl;
Sleep(700);
system("cls");
cout<<" 人人"<<endl;
cout<<" 人人"<<endl;
cout<<" 人人"<<endl;
cout<<" 人人"<<endl;
cout<<" 人人"<<endl;
cout<<" 人人"<<endl;
cout<<" 人人"<<endl;
cout<<" 人人"<<endl;
cout<<" 人人"<<endl;
cout<<" 人人人"<<endl;
cout<<" 人人人人"<<endl;
cout<<" 人人 人人"<<endl;
cout<<" 人人 人人"<<endl;
cout<<" 人人 人人"<<endl;
cout<<" 人人 人人"<<endl;
cout<<" 人人 人人"<<endl;
cout<<" 人人 人人"<<endl;
cout<<" 人人 人人"<<endl;
cout<<" 人人 人人"<<endl;
cout<<" 人人 人人"<<endl;
cout<<" 人人"<<endl;
Sleep(700);
system("cls");
}
int part1()
{
outcolor(WHITE);
out("游戏难度:(如果游戏难度是隐藏级,或者游戏难度是竖着的,请一定要做好心理准备)");
Sleep(1000);
outcolor(RED);
cout<<"隐 "<<endl<<endl;
Sleep(300);
cout<<"藏 "<<endl<<endl;
Sleep(300);
cout<<"级 "<<endl<<endl;
Sleep(300);
outcolor(WHITE);
system("cls");
out("每章提示:");
startkey();
out("游戏开始之前,请告诉我你的名字");
cin>>yourname;
out("你的个人信息:");
out("年龄:23");
out("性别:男");
string s="名字:";
for(int i=0;i<s.size();i++)
{
cout<<s[i];
Sleep(30);
}
for(int i=0;i<s.size();i++)
{
cout<<yourname[i];
if(yourname[i]!=' ')
{
Sleep(30);
}
}
cout<<endl<<endl;
out("住所:上海徐汇区田林的一座房子,面积挺大");
out("学历:本科生");
out("户口:你是一个土生土长的桑黑宁(上海人)");
out("你有一个妹妹,叫赵宛晴,在超市当店长,颜值极品");
out("你有一个好兄弟,叫李文湛,在公司上班,热爱运动,擅长格斗和健身");
out("剧情开始");
outcolor(RED);
out("午夜坤时,乌云密布");
out("天空以肉眼可见的速度,渐渐化为浅绛,随后红色从天空中铺陈开来,最后又化为了深红");
out("你从睡梦中猛然惊醒");
outcolor(WHITE);
out("你决定?");
out("A,去阳台观察天空");
out("B,锁门");
out("请按下对应的键盘按键");
char c=getch();
system("cls");
if(c=='a'||c=='A')
{
out("你来到了阳台");
out("你望向天空……");
outcolor(RED);
out("你被天空的颜色吓到了");
out("你非常恐惧,月亮似乎感觉到你,在一秒中内变为红色!");
out("你的心中已经暗自后悔了这个决定");
out("你撒腿就跑,但是已经晚了");
out("你的意识被传送到了一条红色长廊,四周只有血红的镜子");
out("走廊里全是骷髅头,一望无际的骷髅头,他们就如同你心中的恐惧,如同你躁动的情绪");
out("走廊传来一种说不出来是什么声音的鸣叫,是猫头鹰?是狼?是……");
out("你突然想到了什么,一直往前跑");
out("知道你的意志被慢慢磨灭,精神受到了无尽的折磨,肾上激素被压榨殆尽,你还是倒下了");
die(1);
return -1;
}
else
{
out("你将家门和阳台门锁了起来,");
out("你快速清点了一下物资");
addfood("面包",10);
addfood("水",5);
addfood("罐头",3);
food();
out("突然,敲门声传入耳畔,敲门声又响又急促,连续不断,那声音仿佛在催命!你的心悬到了极点,你决定?");
out("A,开门") ;
out("B,不理");
out("C,通过门眼查看外面");
out("请按下对应的键盘按键");
c=getch();
system("cls");
if(c=='a'||c=='A')
{
outcolor(RED);
out("打开门的瞬间,伪人破门而入,如潮水般用来");
die(2);
return -1;
}
else if(c=='b'||c=='B')
{
out("你的汗毛隆起");
out("幸好一段时间后,你并没有事");
out("时间悄然流逝,你从厨房拿了一把刀防身");
out("你和李文湛住在一起,吵闹声吵醒了他,他向打开门,向你走来");
out("此时的你决定?");
out("A,让他别动,否则杀了他");
out("B,杀了他");
out("请按下对应的键盘按键");
c=getch();
if(c=='a'||c=='A')
{
out("你问了他几个问题,他都回答了上来,并且至始至终都表现的很自然");
out("你让他证明他不是伪人");
out("他很诧异,意识到你怀疑他是伪人,并且这不是在演戏");
out("他说:");
out("我欠了你1145元,到现在都没还,对吧");
out("你的牙膏为什么用的那么快,是因为是我蹭的");
out("有一次,你的外卖被偷了,其实是我吃的");
out("虽然你相信他不是伪人了,但是不知道为什么,你心中突然感觉很生气,想杀了他,但你还是忍住了");
out("他将物资与你合在一起");
addfood("面包",5);
addfood("罐头",5);
addfood("压缩饼干",4);
food();
eatfood();
out("你们吃了些东西,但你们总感觉食物减少的不太对劲");
Sleep(400);
food();
out("第一章,完!");
return 0;
}
else
{
out("你以极快的速度向他靠近,手拿着的刀即将触碰到他的脖子");
out("他用他的手将你的手腕牢牢抓住");
out("他以为要杀了他,于是将你反杀了");
die(3);
return -1;
}
}
else
{
out("你查看了门眼");
Sleep(700);
outcolor(RED);
cout<<"突然,一张脸向门眼袭来,它脸色发白,嘴巴要咧到耳朵跟,传出非男费女的笑声";
Sleep(100);
cout<<"你猛地后退,却看到一个不明生物以极快的速度和绝对直线的轨迹而且不移动身体就向你袭来!";
Sleep(1500);
die(2);
return -1;
}
}
return 0;
}
int game()
{
start();
if(part1())
{
return -1;
}
return -1;
}
int main()
{
out("提示:");
out("请全屏游玩");
out("请将输入法改为英文模式");
out("该游戏不适合:心脏病,幽闭恐惧症等症状的人游玩。");
out("你确定开始游戏吗?");
out("按A键:确定");
out("按B键:新手指南");
out("按其他任意键:退出");
char c=getch();
if(c=='a'||c=='A')
{
if(game()==-1)
{
return 0;
}
}
else if(c=='b'||c=='B')
{
xitian();
}
else
{
return 0;
}
return 0;
}
大家可以将修改后的代码放到评论区!!!