diff --git a/README.md b/README.md index 28a499c..ea6ec35 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ This version is for Windows only. Chinese output or comments may be garbled, so 此版本只适用于Windows。中文的输出或注释可能出现乱码,可以进行反馈或转码(代码使用编码:GB2312)。 +The newly introduced portable version of Linux may damage the experience. + +新推出了linux的移植版本,体验可能受损。 + ## 版本 ### V2.2 diff --git a/linux-version/README.md b/linux-version/README.md new file mode 100644 index 0000000..28a499c --- /dev/null +++ b/linux-version/README.md @@ -0,0 +1,121 @@ +# My-Map +## 注意事项 +This version is for Windows only. Chinese output or comments may be garbled, so feedback or transcoding can be performed (code usage code: GB2312). + +此版本只适用于Windows。中文的输出或注释可能出现乱码,可以进行反馈或转码(代码使用编码:GB2312)。 + +## 版本 + +### V2.2 + +#### V2.2.4 + +Slightly revised RENAME.md. + +略微改版RENAME.md。 + +#### V2.2.3 + +1. Expand comments. + +2. Change the structure slightly. + +3. New mode: All in one mode. + +1、扩充注释。 + +2、稍微更改结构。 + +3、新增模式:清一色模式。 + +#### V2.2.2 + +Modification of some details. + +一些细节的修改。 + +#### V2.2.1 + +1. New mode setting: Hell mode. + +2. Functional comments are provided for part of the code. + +1、新增模式设置:地狱模式。 + +2、为部分代码提供了功能注释。 + +#### V2.2.0 + +New mode settings: normal mode and developer mode. + +新增模式设置:普通模式和开发者模式。 + +### V2.1 + +#### V2.1.3: + +Merge pop-window-version into main branch. + +合并pop-window-version为main分支。 + +#### V2.1.2 + +Optimization of some details. + +一些细节的优化。 + +#### V2.1.1 + +Optimization of some details. + +一些细节的优化。 + +#### V2.1.0 + +Expand the egg of the previous version and add new achievements. Add language menu option. + +对上一版本的彩蛋进行扩充,新增成就。新增语言菜单选项。 + +### V2.0 + +#### V2.0.0 + +New eggs. Please explore or consult the code yourself. + +新增彩蛋。请自行探索或查阅代码。 + +### V1.3 + +#### V1.3.1 + +Add small balls; Discard the archive function and stop providing it until the bug is fixed. + +新增小球;弃用存档功能,在修复好bug之前不再提供。 + +#### V1.3.0 + +Fix the bug that the ball does not update, and make changes to the screen related help. + +修复小球不更新的bug,并对屏幕相关帮助作出更改。 + +### V1.2 + +#### V1.2.0 +Added the function of importing and exporting documents. + +新增导入导出文档功能。 + +### V1.1 + +#### V1.1.0 +The new portal function can easily reach remote places. + +新增传送门功能,可以方便地到达遥远之地。 + +### V1.0 + +#### V1.0.0 +This is a new Sandbox game. You can create or destroy rocks here, and you can walk freely. More functions are under development. + +这是一个新的沙盒游戏。你在这里可以创建或销毁岩石,也可以自由行走。更多功能开发中。 + diff --git a/linux-version/defines/Eggs.cpp b/linux-version/defines/Eggs.cpp new file mode 100644 index 0000000..df9d9ab --- /dev/null +++ b/linux-version/defines/Eggs.cpp @@ -0,0 +1,100 @@ +#ifndef EGGS_CPP_CPP +#define EGGS_CPP_CPP +#include +#include "Eggs.h" +#include "People.h" +#include "help_func.h" +int Egg::isegg(const int &lang,People &p,Map &h){ + if(lang==English && + h[EGG_POS[English][0][0]][EGG_POS[English][0][1]]==rock){ + has_ach=true; + system(("mode "+to_string(COLS+ADD_COLS)+","+to_string(LINES+ADD_LINE)).c_str()); + } else if(lang==Chinese && + p.at(EGG_POS[Chinese][0][0],EGG_POS[Chinese][0][1])== + People::node(EGG_POS[Chinese][0][0],EGG_POS[Chinese][0][1]) + && p.get_pos().x==EGG_POS[Chinese][0][0] && p.get_pos().y==EGG_POS[Chinese][0][1]) return CHI_egg_1; + else if(lang==unable && + p.get_pos().x==EGG_POS[unable][0][0] && p.get_pos().y==EGG_POS[unable][0][1] + && h[EGG_POS[unable][0][0]][EGG_POS[unable][0][1]]==ball + && p.move_f==rights) return UNABLE_egg_1; + return empty_egg; +} +void Egg::check_run(const int &lang,People &p,Map &h){ + system("clear"); + switch(isegg(lang,p,h)){ + case CHI_egg_1: + { + achs[6]=true; + ::print("恭喜您,发现了彩蛋!\n"); + ::print(">>>"); + string s; + while(getline(cin,s) && s!="quit"){ + if(s=="creater"){ + ::print("c_cpp_a,Github网址:www.github.com/c-cpp-a/My-Map\n"); + } else if(s=="lgker"){ + ::print("哈哈,恭喜您发现了隐藏的彩蛋!\n洛谷账号:c_cpp_a,洛谷UID:346332。\n"); + } else if(s=="Snake"){ + ::print("加载贪吃蛇游戏中……\n"); + usleep(10000);//空留着以后再补 + ::print("加载失败!\n"); + } else{ + ::print("对不起,您输入的不是任何指令。\n"); + } + ::print(">>>"); + } + ::print("已退出!"); + } + break; + case UNABLE_egg_1: + { + achs[7]=true; + ::print("恭喜您,发现了彩蛋!\n"); + ::print("Congratulations, you found the egg!\n"); + ::print("<<<"); + string s; + while(getline(cin,s) && s!="quit"){ + if(s=="D o D o oooo"){ + ::print(s); + ::print("\n挺不错嘛,这个彩蛋可难找到了!\n"); + ::print("Very good. It's hard to find this egg!\n"); + ::print("彩蛋提示:中文、10、传送门。\n"); + ::print("Egg tips: Chinese, 10. Transmission gate.\n"); + } else{ + ::print(s); + ::print("\n"); + } + ::print("<<<"); + } + } + } +} +void Egg::print_ach(){ + auto y=0; + y=ach_print("achievement",y); + if(achs[0]){ + y=ach_print("1.creat your first floor.",y); + } + if(achs[1]){ + y=ach_print("2.creat your first rock.",y); + } + if(achs[2]){ + y=ach_print("3.creat your first portal.",y); + } + if(achs[3]){ + y=ach_print("4.creat your first ball.",y); + } + if(achs[4]){ + y=ach_print("5.first access to the portal",y); + } + if(achs[5]){ + y=ach_print("6.move your ball the first time.",y); + } + if(achs[6]){ + y=ach_print("7.found Chinese egg 1.",y); + } + if(achs[7]){ + y=ach_print("8.found [unable] Egg 1.",y); + } +} + +#endif \ No newline at end of file diff --git a/linux-version/defines/Eggs.h b/linux-version/defines/Eggs.h new file mode 100644 index 0000000..d33f357 --- /dev/null +++ b/linux-version/defines/Eggs.h @@ -0,0 +1,27 @@ +#ifndef EGGS_H_ +#define EGGS_H_ +//include STL +//导入标准库 +#include +#include +//include custom library +//导入自定义库 +#include "def.h" +class People; +class Map; +class Egg{ + private: + bool has_ach=false; + bool achs[10]={}; + public: + int isegg(const int &,People &,Map &); + void check_run(const int &,People &,Map &); + void print_ach(); + inline bool is_ach(){ + return has_ach; + } + inline bool &operator[](size_t i){ + return achs[i]; + } +}; +#endif diff --git a/linux-version/defines/Map.cpp b/linux-version/defines/Map.cpp new file mode 100644 index 0000000..8ce6d0d --- /dev/null +++ b/linux-version/defines/Map.cpp @@ -0,0 +1,89 @@ +void Map::print(int x,int y,const int &direct){ + gotoxy(0,0); + if(x>=COLS/2 && y>=LINES/2){ + for(int i=x-LINES/2+1;i<=x+LINES/2;i++){ + for(int j=y-COLS/2+1;j<=y+COLS/2;j++){ + if(i==x && j==y){ + putchar('#'); + continue; + } + map_print(a[i][j]); + } + putchar('\n'); + } + } else if(x>=COLS/2){ + for(int i=x-LINES/2+1;i<=x+LINES/2;i++){ + for(int j=1;j<=COLS;j++){ + if(i==x && j==y){ + putchar('#'); + continue; + } + map_print(a[i][j]); + } + putchar('\n'); + } + } else if(y>=COLS/2){ + for(int i=1;i<=LINES;i++){ + for(int j=y-COLS/2+1;j<=y+COLS/2;j++){ + if(i==x && j==y){ + putchar('#'); + continue; + } + map_print(a[i][j]); + } + putchar('\n'); + } + } else{ + for(int i=1;i<=LINES;i++){ + for(int j=1;j<=COLS;j++){ + if(i==x && j==y){ + putchar('#'); + continue; + } + map_print(a[i][j]); + } + putchar('\n'); + } + } + if(::mode==debugger){ + string contents="pos=("+to_string(x)+","+to_string(y)+"),direct="+direct_content[::lang][direct]; + gotoxy(0,COLS); + cout << contents; + } +} +void Map::change(int x,int y,int c){ + a[x][y]=c; + downx=max(downx,x); + righty=max(righty,y); +} +bool Map::issave(int x,int y){ + return a[x][y]!=rock; +} +//void Map::imports(){ +// ifstream fin; +// fin.open(SAVE_NAME); +// fin >> downx >> righty; +// for(int i=1;i<=downx;i++){ +// for(int j=1;j<=righty;j++){ +// char ch; +// fin >> ch; +// a[i][j]=ch; +// } +// } +// fin.close(); +//} +//void Map::save(){ +// ofstream fout; +// fout.open(SAVE_NAME); +// fout << downx << ' ' << righty; +// for(int i=1;i<=downx;i++){ +// for(int j=1;j<=righty;j++){ +// fout << a[i][j] << ' '; +// } +// fout << '\n'; +// } +// fout.close(); +//} +map Map::operator[](const int i){ + return a[i]; +} diff --git a/linux-version/defines/Map.h b/linux-version/defines/Map.h new file mode 100644 index 0000000..6f44b29 --- /dev/null +++ b/linux-version/defines/Map.h @@ -0,0 +1,23 @@ +#ifndef MAP_H_ +#define MAP_H_ +//include STL +//导入标准库 +#include +#include +//include custom library +//导入自定义库 +#include "def.h" +using namespace std; +class Map{ + private: + map> a; + int downx=0,righty=0; + public: + void print(int,int,const int &); + void change(int,int,int); + bool issave(int,int); +// void imports(); +// void save(); + map operator[](const int i); +}; +#endif diff --git a/linux-version/defines/People.cpp b/linux-version/defines/People.cpp new file mode 100644 index 0000000..9ee4fcf --- /dev/null +++ b/linux-version/defines/People.cpp @@ -0,0 +1,181 @@ +#ifndef PEOPLE_CPP_CPP +#define PEOPLE_CPP_CPP +#include +#include +#include "People.h" +#include "init.h" +bool People::node::operator!=(const People::node a) const{ + return x!=a.x || y!=a.y; +} +bool People::node::operator==(const People::node a) const{ + return x==a.x && y==a.y; +} +bool People::node::check(){ + return x>=1 && y>=1; +} +People::node People::check_xy(node x,const int &func){ + node res=x; + switch(func){ + case ups: + res.x--; + break; + case downs: + res.x++; + break; + case lefts: + res.y--; + break; + case rights: + res.y++; + break; + } + return (res.check()?res:x); +} +const int People::back(const int &func){ + switch(func){ + case ups: + return downs; + case downs: + return ups; + case lefts: + return rights; + case rights: + return lefts; + } + return func; +} +void People::set_f(Map &h,Egg &egg){ + int a=getchar(); + switch(a){ + case 'W':case 'w': + if(!h.issave(pos.x-1,pos.y)) break; + if(pos.x>1){ + pos.x--; + move_f=ups; + } + break; + case 'A':case 'a': + if(!h.issave(pos.x,pos.y-1)) break; + if(pos.y>1){ + pos.y--; + move_f=lefts; + } + break; + case 'S':case 's': + if(!h.issave(pos.x+1,pos.y)) break; + pos.x++; + move_f=downs; + break; + case 'D':case 'd': + if(!h.issave(pos.x,pos.y+1)) break; + pos.y++; + move_f=rights; + break; + case 'H':case 'h': + system("clear"); + print_helper(); + case '1': + { + auto tmp=check_xy(pos,move_f); + h.change(tmp.x,tmp.y,floor); + doors[tmp.x][tmp.y]=default_node; + if(egg.is_ach()) egg[0]=true; + } + break; + case '2': + { + auto tmp=check_xy(pos,move_f); + h.change(tmp.x,tmp.y,rock); + doors[tmp.x][tmp.y]=default_node; + if(egg.is_ach()) egg[1]=true; + } + break; + case '3': + { + int input=0; + auto tmp=check_xy(pos,move_f),tmp2=tmp; + h.change(tmp.x,tmp.y,door); + while(input!=' '){ + h.print(tmp2.x,tmp2.y,move_f); + create_door_helper(); + input=getchar(); + switch(input){ + case 'W':case 'w': + if(tmp2.x>1) tmp2.x--; + break; + case 'A':case 'a': + if(tmp2.y>1) tmp2.y--; + break; + case 'S':case 's': + tmp2.x++; + break; + case 'D':case 'd': + tmp2.y++; + break; + } + } + doors[tmp.x][tmp.y]=tmp2; + if(egg.is_ach()) egg[2]=true; + } + break; + case '4': + { + auto tmp=check_xy(pos,move_f); + h.change(tmp.x,tmp.y,ball); + doors[tmp.x][tmp.y]=default_node; + if(egg.is_ach()) egg[3]=true; + } + break; + case 'L':case 'l': + system("clear"); + set_lang(); + break; + case 'T':case 't': + system("clear"); + settings(); + break; + + } + if(doors[pos.x][pos.y]!=default_node){ + auto tmp=pos; + pos.x=doors[tmp.x][tmp.y].x; + pos.y=doors[tmp.x][tmp.y].y; + if(egg.is_ach()) egg[4]=true; + } else if(h[pos.x][pos.y]==ball){ + auto tmp=pos; + bool flag=true; + while(h[tmp.x][tmp.y]!=floor){ + if(h[tmp.x][tmp.y]==rock || !tmp.check()){ + flag=false; + break; + } + tmp=check_xy(tmp,move_f); + } + if(flag){ + h.change(tmp.x,tmp.y,ball); + h.change(pos.x,pos.y,floor); + if(egg.is_ach()) egg[5]=true; + } else{ + pos=check_xy(pos,back(move_f)); + } + } +} +void People::put_xy(Map &h){ + h.print(pos.x,pos.y,move_f); +} +//void People::save(Map &h){ +// ofstream fout; +// fout.open(SAVE_NAME); +// h.save(); +// fout << endl << x << ' ' << y << endl; +// fout.close(); +// +//} +//void People::imports(Map &h){ +// ifstream fin; +// fin.open(SAVE_NAME); +// h.imports(); +// fin >> x >> y; +// fin.close(); +//} +#endif \ No newline at end of file diff --git a/linux-version/defines/People.h b/linux-version/defines/People.h new file mode 100644 index 0000000..427b3e6 --- /dev/null +++ b/linux-version/defines/People.h @@ -0,0 +1,48 @@ +#ifndef PEOPLE_H_ +#define PEOPLE_H_ +//include STL +//导入标准库 +#include +#include +//include custom library +//导入自定义库 +#include "def.h" +#include "Map.h" +#include "Eggs.h" +class People{ + public: + friend class Egg; + public: + struct node{ + int x,y; + node(int xx=-1,int yy=-1):x(xx),y(yy){} + bool operator!=(const node a) const; + bool operator==(const node a) const; + bool check(); + node &operator=(const node &)=default; + }; + static const node default_node; + private: + int move_f=defaults,lang; + node pos; + map > doors; + node check_xy(node x,const int &func); + const int back(const int &); + public: + People():move_f(defaults),lang(unable),pos({1,1}){} + void set_f(Map &,Egg &); + void put_xy(Map &); + inline const node at(int x,int y){ + return doors[x][y]; + } + inline const node get_pos(){ + return pos; + } + inline const int &get_movef(){ + return move_f; + } +// void save(Map &); +// void imports(Map &); +}; +const People::node People::default_node={-1,-1}; +#endif diff --git a/linux-version/defines/def.h b/linux-version/defines/def.h new file mode 100644 index 0000000..2625922 --- /dev/null +++ b/linux-version/defines/def.h @@ -0,0 +1,69 @@ +/* + * 作者:c_cpp_a(Github) + * 最近更新:2022/12/4 + * 功能简述:这是游戏的基本定义部分。负责常量、enum。当然为了游戏的编写方便,这里的显示字符映射使用了std::map。 + */ +//For some reasons, the English version notes will not be displayed here. +#ifndef DEF +#define DEF +//include STL +//导入标准库 +#include +enum{//地图里面的方向 + defaults,//默认 + ups,//上 + downs,//下 + lefts,//左 + rights//右 +}; +enum{//地图的基本元素 + floor,//空地(默认) + rock,//岩石 + door,//传送门 + ball//小球 +}; +enum{//游戏的语言 + unable,//未定义(默认) + Chinese,//中文 + English//英文 +}; +enum{//彩蛋的类型 + empty_egg, //空彩蛋(默认,就是没有彩蛋) + CHI_egg_1,//中文彩蛋1 + UNABLE_egg_1//[未命名]彩蛋1 +}; +enum{//游戏模式 + normal,//正常(默认) + debugger,//开发者模式 + infernal,//地狱模式 + AIOC//清一色模式 + /* + * 目前的模式的介绍: + * 普通模式:普普通通的,一切都按正常的来 + * 开发者模式:显示坐标,以后还会显示别的东西。 + * 地狱模式:把所有东西都弄到屏幕的左边,总之是非常难。 + * 清一色模式:所有的东西(空地除外)都显示成-,让你猜。 + */ +}; +std::map print_c={//对应元素显示成什么样 + {floor,' '}, + {rock,'-'}, + {door,'@'}, + {ball,'o'} +}; +const int COLS=100,LINES=50;//游戏的窗口大小 +const int ADD_COLS=20,ADD_LINE=10;//成就的新增窗口大小 +const int MODE_COUNT=4,LANGUAGE_COUNT=3,DIRECT_COUNT=5;//模式的种数、语言的种数和方向的种数 +const char SAVE_NAME[]="data.mymap";//保存文件名(未实装) +const int EGG_POS[LANGUAGE_COUNT][10][2]={{5,5},{10,10},{2,2}};//EGG_POS[language][egg_number]={x,y},存储彩蛋的触发坐标 +const char mode_content[LANGUAGE_COUNT][MODE_COUNT][101]={//模式的介绍(mode_content[language][mode]=s) + {},//未定义的自然什么都没有啦 + {"正常的模式","开发者模式","地狱的模式","清一色模式"},//中文 + {"normal","debugger","infernal","all in one color"}//英文 +}; +const char direct_content[LANGUAGE_COUNT][DIRECT_COUNT][101]={//方向对应的名称 + {},//未定义的自然什么都没有啦 + {"?","上","下","左","右"},//中文 + {"?","up","down","left","right"}//英文 +}; +#endif diff --git a/linux-version/defines/help_func.cpp b/linux-version/defines/help_func.cpp new file mode 100644 index 0000000..e9c0629 --- /dev/null +++ b/linux-version/defines/help_func.cpp @@ -0,0 +1,53 @@ +#ifndef HELP_FUNC_CPP_CPP +#define HELP_FUNC_CPP_CPP +#include +#include +#include +#include +#include "def.h" +#include "help_func.h" +namespace{ + using namespace std; + void print(const string s){ + for(std::size_t len=s.length(),i=0;i=ADD_COLS-1){ + gotoxy(COLS+2,starty+i); + cout << string(tmp.begin(),tmp.begin()+ADD_COLS-2); + tmp.erase(tmp.begin(),tmp.begin()+ADD_COLS-2); + i++; + } + gotoxy(COLS+2,starty+i); + cout << tmp; + return starty+i+1; + } + void map_print(const char &ch){ + switch(::mode){ + case normal:case debugger: + putchar(print_c[ch]); + break; + case infernal: + if(ch){ + putchar(print_c[ch]); + } + break; + case AIOC: + if(ch){ + putchar('-'); + } else{ + putchar(' '); + } + break; + } + } +} +#endif \ No newline at end of file diff --git a/linux-version/defines/help_func.h b/linux-version/defines/help_func.h new file mode 100644 index 0000000..3a17995 --- /dev/null +++ b/linux-version/defines/help_func.h @@ -0,0 +1,19 @@ +#ifndef HELP_FUNC_H_H_ +#define HELP_FUNC_H_H_ +//include STL +//导入标准库 +#include +#include +//include custom library +//导入自定义库 +#include "def.h" +namespace{ + using namespace std; + int lang=unable; + int mode=normal; + void print(const string s); + void gotoxy(short x,short y); + int ach_print(const string s,short starty); + void map_print(const char &ch); +} +#endif diff --git a/linux-version/defines/init.cpp b/linux-version/defines/init.cpp new file mode 100644 index 0000000..5258ca3 --- /dev/null +++ b/linux-version/defines/init.cpp @@ -0,0 +1,143 @@ +#ifndef INIT_CPP_CPP +#define INIT_CPP_CPP +#include "def.h" +#include "init.h" +#include "help_func.h" +#include +#include +void set_parameters(){ + system("title 我的地图"); + system(("mode "+to_string(COLS)+","+to_string(LINES+ADD_LINE)).c_str()); +} +void set_lang(){ + system("clear"); + ::lang=unable; + ask:cout << "Please Choose language.\n请设置语言。\n" + "Press'e'to set the language to English, and press'c' to set the language to Chinese.\n" + "按'e'键设置语言为英文,按'c'键设置语言为中文。\n"; + ::lang=getchar(); + if(::lang=='c') ::lang=Chinese; + else if(::lang=='e') ::lang=English; + else if(::lang==224) ::lang=unable; + else{ + cout << "Error:cannot set this language.\n" + "错误:不能设置为此语言。\n"; + goto ask; + } +} +void set_import(People &p,Map &h){ +// int ifimport=0; + if(lang==Chinese){ + //language:Chinese + //语言:中文 +// cout << "请问您是否要导入存档?如果不导入,存档可能丢失。(本功能测试中)\n"; +// cout << "按'y'键导入存档。"; +// ifimport=getchar(); +// if(ifimport=='y'){ +// p.imports(h); +// } + cout << "此功能暂时空缺。按任意键继续…\n"; + getchar(); + system("clear"); + } else{ +// cout << "Do you want to import the archive? If you do not import, the archive may be lost.(in this function test)\n"; +// cout << "Press the 'y' key to import the archive."; +// if(ifimport=='y'){ +// p.imports(h); +// } + cout << "This function is temporarily unavailable. Press any key to continue...\n"; + getchar(); + system("clear"); + } + system("clear"); +} +void screen_helper(){ + using namespace std; + if(lang==Chinese){ + //language:Chinese + //语言:中文 + cout << "\n按H键弹出帮助。\n按T键弹出设置。" << endl; + } else if(lang==English){ + //language:English + //语言:英文 + cout << "\nPress the H key to pop up the help.\nPress the T key to pop up the settings." << endl; + } +} +void print_helper(){ + using namespace std; + if(::lang==Chinese){ + //language:Chinese + //语言:中文 + cout << "\n :空地,可走动\t-:岩石,不可走动\t@:传送门\to:小球\t#:你自己\n" + "WASD移动,按1键将在前进方向上清除一切," + "按2键将在前进方向上创建岩石。" + "按3键将在前进方向上创建传送门。" + "按4键将在前进方向上创建球。\n" + "按l键选择语言。\n" + "更多功能拓展中。。。(请按H键关闭帮助)" << endl; + } else if(::lang==English){ + //language:English + //语言:英文 + cout << "\n :open space, movable\t-: rock, not movable\t@: portal\to: ball\t#: yourself\n" + "WASD moves, pressing the 1 key will clear everything in the forward direction," + "Press 2 to create the rock in the forward direction." + "Pressing the 3 key will create a portal in the forward direction." + "Pressing the 4 key creates a ball in the forward direction.\n" + "Press l to select the language.\n" + "More function expansion...(Press H to close the help)" << endl; + } + char a; + do{ + a=getchar(); + if(a=='l' || a=='L') set_lang(); + }while(a!='H' && a!='h'); +} +void create_door_helper(){ + if(::lang==Chinese){ + //language:Chinese + //语言:中文 + cout << "\nWASD键移动,空格键确认放置传送门。\n"; + } else if(::lang==English){ + //language:English + //语言:英文 + cout << "\nWASD key to move, and space key to confirm to place the transfer door.\n"; + } +} +void settings(){ + int choose; + do{ + system("clear"); + if(::lang==Chinese){ + //language:Chinese + //语言:中文 + cout << "模式:"; + } else if(::lang==English){ + //language:English + //语言:英文 + cout << "pattern:"; + } + cout << mode_content[lang][::mode]; + if(::lang==Chinese){ + //language:Chinese + //语言:中文 + cout << "\n按左右键选择,按q键退出。"; + } else if(::lang==English){ + //language:English + //语言:英文 + cout << "\nPress the left and right keys to select, and press the q key to exit."; + } + choose=getchar(); + if(choose==224){ + choose=getchar(); + } + switch(choose){ + case 77://右键 + ::mode=(::mode+1)%MODE_COUNT; + break; + case 75://左键 + ::mode=(::mode-1+MODE_COUNT)%MODE_COUNT; + break; + } + } while(choose!='q' && choose!='Q'); +} +#endif \ No newline at end of file diff --git a/linux-version/defines/init.h b/linux-version/defines/init.h new file mode 100644 index 0000000..b9ddb2c --- /dev/null +++ b/linux-version/defines/init.h @@ -0,0 +1,29 @@ +#ifndef INIT_H_ +#define INIT_H_ +//include STL +//导入标准库 +#include +#include +#include +#include +#include +using namespace std; +//include custom library +//导入自定义库 +#include "def.h" +#include "People.h" +#include "Map.h" +void create_door_helper(); +void set_parameters(); +void set_lang(); +void set_import(People &,Map &); +void screen_helper(); +void print_helper(); +inline void init(People &p,Map &h){ + set_parameters(); + set_lang(); + system("clear"); + set_import(p,h); +} +void settings(); +#endif diff --git a/linux-version/gmon.out b/linux-version/gmon.out new file mode 100644 index 0000000..cf8e2c3 Binary files /dev/null and b/linux-version/gmon.out differ diff --git a/linux-version/main.cpp b/linux-version/main.cpp new file mode 100644 index 0000000..335b060 --- /dev/null +++ b/linux-version/main.cpp @@ -0,0 +1,52 @@ +/* + * 作者:c_cpp_a(Github) + * 最近更新:2022/12/4 + * 功能简述:这是整个游戏的主体部分,负责运行游戏。 + */ +/* + * Author: c_ cpp_ a(Github) + * Last updated: 2022/12/4 + * Function description: This is the main part of the whole game, responsible for running the game. + */ +//include STL +//导入标准库 +#include +#include +//include custom library +//导入自定义库 +class Map; +class People; +class Egg; +#include "defines/def.h" +#include "defines/help_func.h" +#include "defines/Eggs.h" +#include "defines/Map.h" +#include "defines/People.h" +#include "defines/help_func.cpp" +#include "defines/init.h" +#include "defines/Eggs.cpp" +#include "defines/Map.cpp" +#include "defines/People.cpp" +#include "defines/init.cpp" +using namespace std; +int main(){ + //Instantiate Object + //实例化对象 + Map G; + People p; + Egg egg; + init(p,G);//调用初始化函数(Call initialization function) + //游戏循环(Game cycle) + //游戏的刷新速度=100次/秒(Running speed of the game=100ticks/second) + while(true){ +// p.save(G);//保存游戏(未实装) + p.put_xy(G);//输出(print) + screen_helper();//提供帮助(Help) + if(egg.is_ach()) egg.print_ach();//如果触发了成就系统,就运行输出成就(If the achievement system is triggered, run the output achievement) + usleep(100);//游戏的刷新时间 + p.set_f(G,egg);//输入(input) + egg.check_run(::lang,p,G);//检测是否触发彩蛋(Check whether the egg is triggered) + } + return 0; +} + diff --git a/linux-version/main.exe b/linux-version/main.exe new file mode 100644 index 0000000..2560725 Binary files /dev/null and b/linux-version/main.exe differ