#ifdef __cplusplus #include <cstdio> #include <cstdlib> #include <ctime> #include <random> #else #include <stdio.h> #include <stdlib.h> #include <time.h> #endif #include <conio.h> #include <windows.h> #ifndef getch #define getch _getch #endif #ifndef kbhit #define kbhit _kbhit #endif
//random functions. #ifdef __cplusplus std::mt19937 randint((unsigned)time(nullptr)); void randinit(){} bool randbool(){ return randint() & 1u; } #else void randinit(){ srand((unsigned)time(NULL)); } unsigned randint(){ return rand() ^ rand() << 8 ^ rand() << 16 ^ rand() << 24; } int randbool(){ return randint() & 1u; } #endif int randmod(const unsigned pmod){ return randint() % pmod; } int randrange(const int left, const int right){ return ((int)randint() & 2147483647) % (right - left) + left; } int randrangestep(const int left, const int right, const int step){ return ((int)randint() & 2147483647) % ((right + step - left - 1) / step) * step + left; }
//winctrl functions. HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); void gotoscreen(SHORT x, SHORT y){ SetConsoleCursorPosition(handle, (COORD){x, y}); } void setcolor(WORD color){ SetConsoleTextAttribute(handle, color); } void hidecursor(){ CONSOLE_CURSOR_INFO CursorInfo; GetConsoleCursorInfo(handle, &CursorInfo); CursorInfo.bVisible = 0; SetConsoleCursorInfo(handle, &CursorInfo); } void showcursor(){ CONSOLE_CURSOR_INFO CursorInfo; GetConsoleCursorInfo(handle, &CursorInfo); CursorInfo.bVisible = 1; SetConsoleCursorInfo(handle, &CursorInfo); }
//function with resting-time. int wait(const int sleepTime, const int times){ clock_t edtm; if (!sleepTime || !times){ return sleepTime; } while (kbhit()){ getch(); } edtm = sleepTime * times + clock(); while (edtm > clock()){ if (kbhit()){ return 0; } } return sleepTime; }
//strict | fast, input & print, functions. int inputint(const int length, const int base){ int num = (int)malloc(sizeof(int) * (length + 1)), index = 0, number = 0, i = 0; while (kbhit()){ getch(); } showcursor(); while (1){ num[index] = getch(); if (num[index] == 13 || num[index] == 10){ if (index){ num[index] = 0; break; } printf(“\a”); } else if(num[index] == 8){ if (index){ —index; printf(“\b \b”); } else{ printf(“\a”); } } else if(num[index] == 43 && !index && length > 1){ putchar(43); num[index++] = 0; } else if(num[index] == 45 && !index && length > 1){ putchar(45); num[index++] = -1; } else if(num[index] > 47 && num[index] < 58 && num[index] < 48 + base || num[index] > 64 && num[index] < 91 && num[index] < 55 + base || num[index] > 96 && num[index] < 123 && num[index] < 87 + base){ if (index == length){ printf(“\a”); } else if(num[index] < 58){ putchar(num[index]); num[index++] -= 48; } else if(num[index] < 91){ putchar(num[index]); num[index++] -= 55; } else{ putchar(num[index]); num[index++] -= 87; } } else{ printf(“\a”); } } hidecursor(); if (num[0] < 0){ i = 1; } for (; i < index; ++i){ number = number * base + num[i]; } if (num[0] < 0){ number = ~number + 1; } free(num); return number; } int printint(const int numm, const int base){ int outstr[32], tail = 1, num = numm; if (num >> 31){ putchar(45); num = -num; } *outstr = num % base + 48; if (*outstr > 57){ *outstr += 39; } while (num /= base){ outstr[tail] = num % base + 48; if (outstr[tail] > 57){ outstr[tail] += 39; } ++tail; } while (tail—){ putchar(outstr[tail]); } return numm; } int slow(const char *str, const int sleepTime){ int sltm = sleepTime; while (kbhit()){ getch(); } if (sleepTime){ while (*str && sleepTime){ putchar(*str++); if (!wait(sleepTime, 1)){ sltm = 0; break; } } } printf(str); return sltm; } void pause(const int lang){ while (kbhit()){ getch(); } if (lang == 1){ printf(“请按任意键继续…”); } else if(lang == 2){ printf(“Press any key to continue …”); } getch(); puts(""); } void spaces(const int left, const int right){ int i = left; while (i++ < right){ putchar(32); } } void endline(){ puts(""); }
//variables & constants:
//character data; typedef struct{ const char *ChineseName; const char *EnglishName; unsigned food; unsigned money; unsigned deadtimes; }character; character person[1]; void initper(const int i, const char *const ChN, const char *const EnN, const unsigned fd, const unsigned mn, const unsigned deadts){ person[i].ChineseName = ChN; person[i].EnglishName = EnN; person[i].food = fd; person[i].money = mn; person[i].deadtimes = deadts; }
//achievement data; typedef struct{ const char *ChineseName; const char *EnglishName; int reached; }achievement; achievement achi[3]; void initachi(const int i, const char *const ChN, const char *const EnN, const int status){ achi[i].ChineseName = ChN; achi[i].EnglishName = EnN; achi[i].reached = status; } void reachachi(const int i, const int lang){ if (!achi[i].reached){ achi[i].reached = 1; system(“cls”); if (lang == 1){ printf(“达成成就[%s]!\n”, achi[i].ChineseName); } else if(lang == 2){ printf(“Achieve [%s]!\n”, achi[i].EnglishName); } pause(lang); } }
//setting; const int langmaxi = 2, persmaxi = 1, achimaxi = 3; int sleeptime, isdebugging, language;
//global data. int day, personindex, scene;
//init functions. void init(){ randinit(); initper(0, “张华阳”, “Aglobal Brown”, 0u, 0u, 0u); initachi(0, “进行一次游戏”, “Start the Game”, 0); initachi(1, “死亡一次”, “Have Died Once”, 0); initachi(2, “拔剑四顾心茫然”, “Draw the Sword, ” “Look Around, and Feel Confused”, 0); sleeptime = 25; isdebugging = 0; language = 1; day = 0; personindex = 0; scene = 0; hidecursor(); system(“mode con cols=80 lines=25”); }
//scene functions:
//Page Head; void sceneHeadFunc(const character *const per){ int nothingflag = 1; if (language == 1){ printf(“%s,你有”, per -> ChineseName); if (per -> food){ printf(“%u份食物,”, per -> food); nothingflag = 0; } if (per -> money){ printf(“%u,", per -> money); nothingflag = 0; } if (nothingflag){ printf("\b\b什么都没有 "); } puts("\b\b。"); } else if(language == 2){ printf("%s, you have", per -> EnglishName); if (per -> food){ printf(" %u package%s of food,", per -> food, per -> food > 1 ? "s" : ""); nothingflag = 0; } if (per -> money){ printf(" %u,”, per -> money); nothingflag = 0; } if (nothingflag){ printf(” nothing ”); } putchar(8); putchar(46); endline(); } if (isdebugging){ printint(scene, 10); putchar(58); } }
//Page 5; int scene15Func(){ scene = 15; system(“cls”); sceneHeadFunc(person + personindex); if (!personindex){ endline(); if (language == 1){ slow(“你在家里摆烂的第一天,食物-1;\n\n” “你在家里摆烂的第二天,食物-1;\n\n…\n\n” “你在家里摆烂的第十天,食物-1;\n\n” “你在家里摆烂的第十一天,食物不足。\n\n” “你饿死了。\n\n”, sleeptime); } else if(language == 2){ slow(“Today is the first day that you stay at home. ” “You eat a package of food.\n\nToday is the second day ” “that you stay at home. You eat a package of food, too.\n\n” ”…\n\nToday is the first day that you stay at home. ” “You have no food.\n\nYou died of hunger.”, sleeptime); } pause(language); ++person[personindex].deadtimes; return 0; } pause(language); return 0; } int scene16Func(){ scene = 16; system(“cls”); sceneHeadFunc(person + personindex); if (!personindex){ int useless; endline(); if (language == 1){ useless = slow(“你感到无聊,于是想出门看看。\n\n”, sleeptime); useless = wait(useless, 100); useless = slow(“你观望四周,发现道路上一个人都没有。\n\n” “你走着,走着,走到了一个岔路口。” “你不知道这是通往哪里的。\n\n” “这时你会:\n” “0.左转\n” “1.右转\n” “2.直行\n” “3.返回\n” “4.获取更多记忆(需要3份食物)\n” “你选择:”, useless); } else if(language == 2){ useless = slow(“You feel bored. ” “You want to go out.\n\n”, sleeptime); useless = wait(useless, 100); useless = slow(“You look around and ” “find no one on the street.\n\n” “You are walking and walking.\n” “Then, you come to a crossing you have never heard.\n” “Then you will:\n” “0.turn left\n” “1.turn right\n” “2.go straight\n” “3.return\n” “4.get more memories (needs 3 packages of food)\n” “Input here: ”, useless); } if ((useless = inputint(1, 5) + 1) == 5){ person[personindex].food -= 3u; gotoscreen(0, 0); sceneHeadFunc(person + personindex); gotoscreen(0, 15); if (language == 1){ slow(“你感到些许记忆冲刷你的脑海。\n\n” “你记起来了:\n” “0.左转(商店方向)\n” “1.右转(图书馆方向)\n” “2.直行(银行方向)\n” “3.返回(回家)\n” “这时你会:”, useless); } else if(language == 2){ slow(“You feel that some memories run back to your home.\n\n” “You remember something like:\n” “0.turn left (to the store)\n” “1.turn right (to the library)\n” “2.go straight (to the bank)\n” “3.return (home)\n” “Then you will (input here): ”, useless); } useless = inputint(1, 4) + 1; } return useless; } pause(language); return 0; }
//Page 4; int scene11Func(){ scene = 11; system(“cls”); sceneHeadFunc(person + personindex); if (!personindex){ int useless; endline(); if (language == 1){ slow(““你手里拿的是什么?”\n” ““没什么。”\n“让我看看!”\n” ““好啊,那就让你看看我大斧头的威力!”\n” “他举起手里的斧头,朝你砍了下去。\n\n” ““谁叫你要说奇奇怪怪的话呢…”他嘟囔着。\n\n”, sleeptime); } else if(language == 2){ slow(""What are you holding?”\n” ""Nothing.”\n”let me have a look!”\n” ""OK, let you look at my axe!”\n” “Then he kills you with the axe.\n\n\n\n”, sleeptime); } pause(language); ++person[personindex].deadtimes; return 0; } pause(language); return 0; } int scene12Func(){ scene = 12; system(“cls”); sceneHeadFunc(person + personindex); if (!personindex){ endline(); if (language == 1){ slow(““你丫的在我房间做什么?给我滚出去!”\n\n” ““你特么…好好好,我滚行了吧。”\n” “他灰溜溜地逃走了。\n\n” “当他走远后,你会:\n” “0.继续摆烂\n” “1.出去看看\n” “你选择:”, sleeptime); } else if(language == 2){ slow(""What are you doing in my room? Leave here!”\n\n” ""Sh… OK, I’ll leave soon.”\n” “Then he runs away from your home.\n\n” “When he leaves far away from your home, you will:\n” “0.stay at home\n” “1.go out\n” “Input here: ”, sleeptime); } return inputint(1, 3) + 1; } pause(language); return 0; } int scene13Func(){ scene = 13; system(“cls”); sceneHeadFunc(person + personindex); if (!personindex){ endline(); if (language == 1){ slow(““你丫的在我房间做什么?给我滚出去!”\n\n” ““你特么…焯!你完了!”\n” “他举起手里的斧头,朝你砍了下去。\n\n”, sleeptime); } else if(language == 2){ slow(""What are you doing in my room? Leave here!”\n\n” ""I… F**k! You’ll die!”\n” “He raises the axe and kills you with it.\n\n”, sleeptime); } pause(language); ++person[personindex].deadtimes; return 0; } pause(language); return 0; } int scene14Func(){ scene = 14; system(“cls”); sceneHeadFunc(person + personindex); if (!personindex){ int useless; endline(); if (language == 1){ useless = slow(““既然你来了,要不我们组建一个探险队吧!”\n\n” ““既然世界上只剩我们两个,那多一个同伴就多一份安全。” “我同意组建一个探险队。”\n\n” “就这样,他加入了你的队伍。食物消耗+1。\n\n”, sleeptime); useless = wait(useless, 100); } else if(language == 2){ useless = slow(""Since you are here, ” “let’s form an exploring team, OK?”\n\n” ""Since there are only us two in the world, ” “the more partners I have, the more safe I feel.” “I agree with you.”\n\n” “That’s it, He joins in your team. ” “Food consumption+1.\n\n”, sleeptime); useless = wait(useless, 100); } return inputint(1, 3) + 1; } pause(language); return 0; }
//Page 3; int scene5Func(){ scene = 5; system(“cls”); sceneHeadFunc(person + personindex); if (!personindex){ endline(); if (language == 1){ slow(“你打开了门,发现外面站着一个人。\n” “他手里拿着斧子,向你砍了过来。\n\n” “Ps: 看来你的耳朵不太好啊,” “听不清声音是从哪里传过来的。\n\n”, sleeptime); } else if(language == 2){ slow(“You open the door and see a man standing outside.\n” “He holds an axe and kills you with it.\n\n” “Ps: Your ears seem to be bad.\n” ” You cannot listen clearly.\n\n”, sleeptime); } pause(language); ++person[personindex].deadtimes; return 0; } pause(language); return 0; } int scene6Func(){ scene = 6; system(“cls”); sceneHeadFunc(person + personindex); if (!personindex){ endline(); if (language == 1){ slow(“你走进卧室,发现里面有个人。\n” “他自我介绍说他叫吴良,发现街道上没人,” “于是他便翻窗进了一户人家,想看看是否所有人都消失了。\n” “他的手一直背在身后,手里好像拿着什么东西。\n\n” “这时你会:\n” “0.叫他把手里的东西拿出来\n” “1.叫他滚出你家\n” “2.邀请他加入你组成探险队\n” “你选择:”, sleeptime); } else if(language == 2){ slow(“You go into the badroom and see a man there.\n” “He said he is John Smith and found nobody on the street.” “Then he flipped the window and go into a room ” “to ckeck out if everyone is disappeared.\n” “His hands are always behind his back and ” “he seems to hold sonthing.\n\n” “Then you will:\n” “0.ask him to show something held by his hand\n” “1.ask him to leave unpolitely\n” “2.invite him to join you and form an exploring team\n” “Input here: ”, sleeptime); } return inputint(1, 3) + 1; } pause(language); return 0; } int scene7Func(){ scene = 7; system(“cls”); sceneHeadFunc(person + personindex); if (!personindex){ int useless; endline(); useless = wait(sleeptime, randrange(64, 101)); if (language == 1){ slow(““焯!不理我是吧!你完了!”\n\n” “紧接着,一个人影从卧室冲出,” “举起消防斧朝你砍了过来。\n\n”, useless); } else if(language == 2){ slow(""Fk! You’ll die!”\n\n” “A man runs towards you from the badroom and ” “kills you with an axe.\nYou died.\n”, useless); } pause(language); ++person[personindex].deadtimes; return 0; } pause(language); return 0; } int scene8Func(){ scene = 8; system(“cls”); sceneHeadFunc(person + personindex); if (!personindex){ endline(); if (language == 1){ slow(““请进。”\n” “随后,你与他交换了信息。\n” “他带来了一些食物,正好够两人吃。\n” “你发现他的手一直背在身后,手里好像拿着什么东西。\n\n” “这时你会:\n” “0.叫他把手里的东西拿出来\n” “1.邀请他加入你组成探险队\n” “你选择:”, sleeptime); } else if(language == 2){ slow(""Sure.”\n” “Then he exchanges some information with you.\n” “He brought some food that will be enough for you two.\n” “You find that his hands are always behind his back and ” “he seems to hold sonthing.\n\n” “Then you will:\n” “0.ask him to show something held by his hand\n” “1.invite him to join you and form an exploreing team\n” “Input here: ”, sleeptime); } return inputint(1, 2) + 1; } pause(language); return 0; } int scene9Func(){ scene = 9; system(“cls”); sceneHeadFunc(person + personindex); if (!personindex){ endline(); if (language == 1){ slow(“你婉拒了他,他走了。\n\n” “这时你会:\n” “0.待在屋里\n” “1.出门看看\n” “你选择:”, sleeptime); } else if(language == 2){ slow(“You refuse him politely and he leaves here.\n\n” “Then you will:\n” “0.stay at home\n” “1.go out\n” “Input here: ”, sleeptime); } return inputint(1, 2) + 1; } pause(language); return 0; } int scene10Func(){ scene = 10; system(“cls”); sceneHeadFunc(person + personindex); if (!personindex){ endline(); if (language == 1){ slow(““你给我滚!”\n\n” ““你特么…焯!你完了!”\n” “他趁你不注意,手刃了你。\n\n”, sleeptime); } else if(language == 2){ slow(""Leave away!”\n” ""I… Fk! You’ll die!”\n” “He killed you when you did not notice.\n\n”, sleeptime); } pause(language); ++person[personindex].deadtimes; return 0; } pause(language); return 0; }
//Page 2; int scene2Func(){ scene = 2; system(“cls”); sceneHeadFunc(person + personindex); if (!personindex){ int useless; endline(); useless = wait(sleeptime, randrange(64, 101)); if (language == 1){ useless = slow(““咚咚咚!”\n\n”, useless); useless = wait(useless, randrange(64, 126)); useless = slow(““咚!咚!咚!”\n\n”, useless); useless = wait(useless, randrange(100, 126)); useless = slow(““焯!不理我是吧!你完了!”\n\n”, useless); useless = wait(useless, 25); useless = slow(“紧接着,一个人影破门而入,” “举起消防斧朝你砍了过来。\n\n喜提死亡次数+1\n\n”, useless); } else if(language == 2){ useless = slow(“\a(Knocking sound) \a(Knocking sound)” ” \a(Knocking sound)\n\n”, useless); useless = wait(useless, randrange(64, 126)); useless = slow(“\a(Loud knocking sound)” ” \a(Loud knocking sound)” ” \a(Loud knocking sound)\n\n”, useless); useless = wait(useless, randrange(100, 126)); useless = slow(""F**k! Open the door! ” “Or you’ll die!”\n\n”, useless); useless = wait(useless, 25); useless = slow(“A man breaks the door and kills you with an axe.” “\n\nYou died.\n\n”, useless); } pause(language); ++person[personindex].deadtimes; return 0; } pause(language); return 0; } int scene3Func(){ scene = 3; system(“cls”); sceneHeadFunc(person + personindex); if (!personindex){ endline(); if (language == 1){ slow(““门外是谁?”你问道。\n\n“门外不是我。”\n\n” “奇怪,这段对话总感觉好像在哪本小说读过。\n\n” ““滚。”你没好气地说了一声。\n\n” ““我没开玩笑。我在你的卧室。”\n” “你仔细听了听,发现声音确实是从你的卧室传来的。\n” “而敲门声其实是敲击桌子发出的。\n\n” ““门外没人。”那个声音说了一句。\n\n” “这时你会:\n” “0.确认门外是否没人\n” “1.确认谁在说话\n” “2.不理不睬\n” “你选择:”, sleeptime); } else if(language == 2){ slow(""Who is knocking the door?”You asked.\n\n” ""It’s not me.”\n\n” “You notice the conversation and wonder it.\n\n” ""You are kidding.” You say angrily.\n\n” ""I am not kidding. I am in your badroom.”\n” “You listen carefully and find the sound in your badroom.\n” “And the knocking sound is from knocking the desk.\n\n” ""There are no people outside the door.”\n\n” “Then you will:\n” “0.check out if there is a man outside\n” “1.check out who is speaking\n” “2.ignore it\n” “Input here: ”, sleeptime); } return inputint(1, 3) + 1; } pause(language); return 0; } int scene4Func(){ scene = 4; system(“cls”); sceneHeadFunc(person + personindex); if (!personindex){ endline(); if (language == 1){ slow(“你打开了门,发现外面站着一个人。\n” “他自我介绍说他叫吴良,发现街道上没人,” “于是想确认是否所有人都消失了。\n” ““我能进去吗?”他说。\n\n” “这时你会:\n” “0.请他进来\n” “1.委婉拒绝\n” “2.态度恶劣地叫他滚出去\n” “你选择:”, sleeptime); } else if(language == 2){ slow(“You open the door and see a man standing outside.\n” “He said he is John Smith and found nobody on the street.” “And he wanted to ckeck out if everyone is disappeared.\n” ""Could I go in?” He asked.\n\n” “Then you will:\n” “0.let him come in\n” “1.refuse him politely\n” “2.shout at him to ask him leave\n” “Input here: ”, sleeptime); } return inputint(1, 3) + 1; } pause(language); return 0; }
//Page 1. int scene1Func(){ scene = 1; system(“cls”); if (language == 1){ printf(“你叫”); sceneHeadFunc(person + personindex); } else if(language == 2){ const char *s = person[personindex].EnglishName; int i = 13; printf(“Your name is ”); sceneHeadFunc(person + personindex); while (*s++){ ++i; } gotoscreen(i, 0); putchar(46); putchar(32); putchar(89); gotoscreen(0, 1); } if (!personindex){ int useless; endline(); if (language == 1){ useless = slow(“你缓缓睁开眼,感觉头部有些疼痛。\n” “你发现你躺在你家沙发上。\n” “你好像失忆了,只能记住以前非常零星的内容。\n” “打开窗户,向外望去,不见一点人影,不闻一点人声,” “好像世界上只剩下了你一人一样。\n\n”, sleeptime); useless = wait(useless, 64); slow(““咚咚咚!”门外响起了敲门声。\n\n” “这时你会:\n” “0.假装听不见\n” “1.回应门外的声音\n” “2.开门看一看\n” “你选择:”, useless); } else if(language == 2){ useless = slow(“You open your eyes slowly, ” “and you feel some pain in your head.\n” “You find yourself lying on the sofa.\n” “You seem to have lost your memory. ” “You only have a few memories from the past.\n” “You open the window and look out. ” “You find no one and hear no sound.” “It seems like that ” “you are the only one human in the world.\n\n”, sleeptime); useless = wait(useless, 64); slow(“Suddenly, there is a knock on the door.\n\n” “Then you will:\n” “0.make as though you do not hear\n” “1.reply the sound\n” “2.open the door\n” “Input here: ”, useless); } return inputint(1, 3) + 1; } pause(language); return 0; }
//starting-page functions. void exitPageFunc(){ int status = 0; system(“cls”); if (language == 1){ SetConsoleTitle(“退出游戏 | 剧情游戏 v1.1.0.1.1.950826”); puts(“确定退出游戏?”); puts(”> 是”); puts(” 否”); puts(“按下回车做出选择。”); } else if(language == 2){ SetConsoleTitle(“Exit | Texed v1.1.0.1.1.950826”); puts(“Are you sure?”); puts(”> Stay”); puts(” Leave”); puts(“Press enter to make your dicision.”); } while (kbhit()){ getch(); } while (1){ int ch = getch(); if (ch == 10 || ch == 13){ if (language == 1){ if (status){ return; } exit(0); } else if(language == 2){ if (status){ exit(0); } return; } return; } if (ch == 224){ ch = getch(); if (ch == 72 && status){ gotoscreen(0, 2); putchar(32); gotoscreen(0, 1); putchar(62); status = 0; } else if(ch == 80 && !status){ gotoscreen(0, 1); putchar(32); gotoscreen(0, 2); putchar(62); status = 1; } else{ printf(“\a”); } } else{ printf(“\a”); } } } void startingPageFunc(){ int useless; if (language == 1){ SetConsoleTitle(“剧情 | 剧情游戏 v1.1.0.1.1.950826”); } else if(language == 1){ SetConsoleTitle(“Playing… | Texed v1.1.0.1.1.950826”); } reachachi(0, language); person[personindex].food = 10u; person[personindex].money = 0u; if (!(useless = scene1Func())){ reachachi(1, language); return; } if (useless == 1){ if (!(useless = scene2Func())){ reachachi(1, language); return; } } else if(useless == 2){ if (!(useless = scene3Func())){ reachachi(1, language); return; } if (useless == 1){ if (!(useless = scene5Func())){ reachachi(1, language); return; } } else if(useless == 2){ if (!(useless = scene6Func())){ reachachi(1, language); return; } if (useless == 1){ if (!(useless = scene11Func())){ reachachi(1, language); return; } } else if(useless == 2){ if (randmod(3u)){ if (!(useless = scene12Func())){ reachachi(1, language); return; } if (useless == 1){ if (!(useless = scene15Func())){ reachachi(1, language); return; } } else if(useless == 2){ if (!(useless = scene16Func())){ reachachi(1, language); return; } } } else{ if (!(useless = scene13Func())){ reachachi(1, language); return; } } } } else if(useless == 3){ if (!(useless = scene7Func())){ reachachi(1, language); return; } } } else if(useless == 3){ if (!(useless = scene4Func())){ reachachi(1, language); return; } if (useless == 1){ if (!(useless = scene8Func())){ reachachi(1, language); return; } if (useless == 1){ if (!(useless = scene11Func())){ reachachi(1, language); return; } } } else if(useless == 2){ if (!(useless = scene9Func())){ reachachi(1, language); return; } if (useless == 1){ if (!(useless = scene15Func())){ reachachi(1, language); return; } } else if(useless == 2){ if (!(useless = scene16Func())){ reachachi(1, language); return; } } } else if(useless == 3){ if (!(useless = scene10Func())){ reachachi(1, language); return; } } } if (language == 1){ puts(“未完成的剧情…”); puts(“建议看看[关于游戏]”); } else if(language == 2){ puts(“Unfinished Ending…”); puts(“You could look through [About]”); } pause(language); } void achievementPageFunc(){ int i = 0; unsigned deadTimes = 0; system(“cls”); if (language == 1){ SetConsoleTitle(“成就 | 剧情游戏 v1.1.0.1.1.950826”); puts(“成就”); for (; i < achimaxi; ++i){ printf(” %s\n”, achi[i].reached ? achi[i].ChineseName : “未达成”); } endline(); for (i = 0; i < persmaxi; ++i){ deadTimes += person[i].deadtimes; } printf(“死亡次数:%u次\n”, deadTimes); } else if(language == 2){ SetConsoleTitle(“Achievements | Texed v1.1.0.1.1.950826”); puts(“Achievements”); for (; i < achimaxi; ++i){ printf(” %s\n”, achi[i].reached ? achi[i].EnglishName : “(Locked)”); } endline(); for (i = 0; i < persmaxi; ++i){ deadTimes += person[i].deadtimes; } if (!deadTimes){ puts(“You have not died.”); } else if(deadTimes == 1){ puts(“You have died once.”); } else if(deadTimes == 2){ puts(“You have died twice.”); } else{ printf(“You have died %d times.\n”, deadTimes); } } pause(language); } void sleeptimePageFunc(){ int status; system(“cls”); if (language == 1){ SetConsoleTitle(“文字速度 | 剧情游戏 v1.1.0.1.1.950826”); puts(“文字速度”); puts(” 瞬 (0ms)”); puts(” 快(10ms)”); puts(” 中(25ms)”); puts(” 慢(50ms)”); puts(“返回请按退格。”); } else if(language == 2){ SetConsoleTitle(“Sentence Speed | Texed v1.1.0.1.1.950826”); puts(“Sentence Speed”); puts(” Quickly(0ms)”); puts(” Fast (10ms)”); puts(” Medium(25ms)”); puts(” Slow (50ms)”); puts(“Press backspace to return.”); } if (!sleeptime){ gotoscreen(0, status = 1); putchar(62); } else if(sleeptime == 10){ gotoscreen(0, status = 2); putchar(62); } else if(sleeptime == 25){ gotoscreen(0, status = 3); putchar(62); } else if(sleeptime == 50){ gotoscreen(0, status = 4); putchar(62); } while (kbhit()){ getch(); } while (1){ int ch = getch(); if (ch == 8){ if (status == 1){ sleeptime = 0; } else if(status == 2){ sleeptime = 10; } else if(status == 3){ sleeptime = 25; } else if(status == 4){ sleeptime = 50; } return; } if (ch == 224){ ch = getch(); if (ch == 72 && status > 1){ gotoscreen(0, status—); putchar(32); gotoscreen(0, status); putchar(62); } else if(ch == 80 && status < 4){ gotoscreen(0, status++); putchar(32); gotoscreen(0, status); putchar(62); } else{ printf(“\a”); } } else{ printf(“\a”); } } } void aboutPageFunc(){ system(“cls”); if (language == 1){ SetConsoleTitle(“关于 | 剧情游戏 v1.1.0.1.1.950826”); puts(“关于游戏”); puts(” 剧情游戏 v1.1.0.1.1.950826”); puts(” 作者:”); puts(” 洛谷UID950826 用户名<qiuby123456>”); puts(” 鸣谢:”); puts(” <被动>洛谷UID92860 用户名<TSzza>”); puts(” 提供了创意”); puts(” <主动>洛谷UID950826 用户名<qiuby123456>”); puts(” 提供了创意”); puts(” 版权所有,侵权必究”); } else if(language == 2){ SetConsoleTitle(“About | Texed v1.1.0.1.1.950826”); puts(“About”); puts(” Texed v1.1.0.1.1.950826”); puts(” Author:”); puts(” LuoguUID950826 Username<qiuby123456>”); puts(” Thanks to:”); puts(” <Passive>LuoguUID92860 Username<TSzza>”); puts(” Provided ideas”); puts(” <Active> LuoguUID950826 Username<qiuby123456>”); puts(” Provided ideas”); puts(” All rights reserved.”); } pause(language); } void debuggingPageFunc(){ int status; system(“cls”); if (language == 1){ SetConsoleTitle(“调试 | 剧情游戏 v1.1.0.1.1.950826”); puts(“调试模式”); puts(” 打开调试”); puts(” 关闭调试”); puts(“返回请按退格。”); } else if(language == 2){ SetConsoleTitle(“Debugging | Texed v1.1.0.1.1.950826”); puts(“Are you debugging?”); puts(” I am debugging”); puts(” I am not debugging”); puts(“Press backspace to return.”); } gotoscreen(0, 2 - isdebugging); putchar(62); while (kbhit()){ getch(); } while (1){ int ch = getch(); if (ch == 8){ return; } if (ch == 224){ ch = getch(); if (ch == 72 && !isdebugging){ gotoscreen(0, 2); putchar(32); gotoscreen(0, 1); putchar(62); isdebugging = 1; } else if(ch == 80 && isdebugging){ gotoscreen(0, 1); putchar(32); gotoscreen(0, 2); putchar(62); isdebugging = 0; } else{ printf(“\a”); } } else{ printf(“\a”); } } } void languagePageFunc(){ system(“cls”); if (language == 1){ SetConsoleTitle(“语言 | 剧情游戏 v1.1.0.1.1.950826”); puts(“调整语言”); puts(”> 简体中文”); puts(” English”); puts(“返回请按退格。”); } else if(language == 2){ SetConsoleTitle(“Language | Texed v1.1.0.1.1.950826”); puts(“Language”); puts(” 简体中文”); puts(”> English”); puts(“Press backspace to return.”); } while (kbhit()){ getch(); } while (1){ int ch = getch(); if (ch == 8){ return; } if (ch == 224){ ch = getch(); if (ch == 72 && language > 1){ —language; } else if(ch == 80 && language < langmaxi){ ++language; } else{ printf(“\a”); continue; } system(“cls”); if (language == 1){ SetConsoleTitle(“语言 | 剧情游戏 v1.1.0.1.1.950826”); puts(“调整语言”); puts(”> 简体中文”); puts(” English”); puts(“返回请按退格。”); } else if(language == 2){ SetConsoleTitle(“Language | Texed v1.1.0.1.1.950826”); puts(“Language”); puts(” 简体中文”); puts(”> English”); puts(“Press backspace to return.”); } } else{ printf(“\a”); } } } void bulletinPageFunc(){ int status = 1; system(“cls”); if (language == 1){ SetConsoleTitle(“公告 | 剧情游戏 v1.1.0.1.1.950826”); puts(” < | 公告”); puts(”--------|”); puts(” 公 告 > 已完成16个剧情页”); puts(”--------|”); puts(“更新日志|”); puts(”--------|”); puts(” |”); } else if(language == 2){ SetConsoleTitle(“Bulletin | Texed v1.1.0.1.1.950826”); puts(” < | Bulletin”); puts(”--------|”); puts(“Bulletin> 16 plot pages have finished”); puts(”--------|”); puts(“Updating|”); puts(”--------|”); puts(” |”); } while (status){ int mouse = 0, i = 0; POINT point; HWND hwnd = GetForegroundWindow(); GetCursorPos(&point); ScreenToClient(hwnd, &point); for (; i < 3; ++i){ if (GetAsyncKeyState(1) && !mouse && i != status && point.x > -1 && point.x < 64 && point.y > (i << 5) - 1 && point.y < (i << 5) + 16){ mouse = 1; gotoscreen(8, status << 1); putchar(32); gotoscreen(8, (status = i) << 1); putchar(62); if (status == 1){ int useless = 3; gotoscreen(10, 0); if (language == 1){ printf(“公告”); spaces(14, 64); gotoscreen(10, 2); printf(” 已完成16个剧情页”); spaces(28, 64); } else if(language == 2){ printf(“Bulletin”); spaces(18, 64); gotoscreen(10, 2); printf(” 16 plot pages have finished”); spaces(39, 64); } for (; useless < 11; ++useless){ gotoscreen(10, useless); spaces(10, 64); } } else if(status == 2){ gotoscreen(10, 0); if (language == 1){ printf(“更新日志”); spaces(18, 64); gotoscreen(10, 2); printf(” v1.1.0.1.1.950826”); spaces(29, 64); gotoscreen(10, 3); printf(” 添加了3个剧情页”); spaces(29, 64); gotoscreen(10, 4); printf(” 使用更好的延时函数”); spaces(32, 64); gotoscreen(10, 5); printf(” 修复了标题语言切换的问题”); spaces(38, 64); gotoscreen(10, 6); printf(” v1.1.0.0.2.950826”); spaces(29, 64); gotoscreen(10, 7); printf(” 添加了公告”); spaces(24, 64); gotoscreen(10, 8); printf(” 在公告页面使用鼠标操作”); spaces(36, 64); gotoscreen(10, 9); printf(” v1.1.0.0.1.950826”); spaces(29, 64); gotoscreen(10, 10); printf(” 添加了13个剧情页”); spaces(30, 64); } else if(language == 2){ printf(“Updating”); spaces(18, 64); gotoscreen(10, 2); printf(” v1.1.0.1.1.950826”); spaces(29, 64); gotoscreen(10, 3); printf(” Add 3 plot pages”); spaces(30, 64); gotoscreen(10, 4); printf(” Change the better ”); printf(“resting-time function”); spaces(53, 64); gotoscreen(10, 5); printf(” Make the language of the title change”); spaces(51, 64); gotoscreen(10, 6); printf(” v1.1.0.0.2.950826”); spaces(29, 64); gotoscreen(10, 7); printf(” Add the bulletins”); spaces(31, 64); gotoscreen(10, 8); printf(” Use mouse operation in Page Bulletins”); spaces(51, 64); gotoscreen(10, 9); printf(” v1.1.0.0.1.950826”); spaces(29, 64); gotoscreen(10, 10); printf(” Add 13 plot pages”); spaces(31, 64); } } } else if(mouse){ mouse = 0; } } } } void homePageFunc(){ int input; while (1){ scene = 0; system(“cls”); if (language == 1){ SetConsoleTitle(“首页 | 剧情游戏 v1.1.0.1.1.950826”); slow(“0-退出游戏\n” “1-开始游戏\n” “2-查看成就\n” “3-文字速度\n” “4-关于游戏\n” “5-调试模式\n” “6-调整语言\n” “7-查看公告\n\n” “请输入序号以进入对应功能。\n\n输入:”, sleeptime); } else if(language == 2){ SetConsoleTitle(“Home | Texed v1.1.0.1.1.950826”); slow(“0-Exit\n” “1-Start\n” “2-Achievements\n” “3-Sentence Speed\n” “4-About\n” “5-Debugging Switch\n” “6-Language\n” “7-Bulletins\n\n” “Press the character on the left of ’-’” ” to achieve its function.\n\nInput: ”, sleeptime); } input = inputint(1, 8); if (!input){ exitPageFunc(); } else if(input == 1){ startingPageFunc(); } else if(input == 2){ achievementPageFunc(); } else if(input == 3){ sleeptimePageFunc(); } else if(input == 4){ aboutPageFunc(); } else if(input == 5){ debuggingPageFunc(); } else if(input == 6){ languagePageFunc(); } else if(input == 7){ bulletinPageFunc(); } } }
//main functions. int main(){ init(); homePageFunc(); return 0; }