diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml deleted file mode 100644 index c08e6a1..0000000 --- a/.github/workflows/c-cpp.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: C/C++ CI - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: configure - run: .\configure - - name: make - run: make - - name: make check - run: make check - - name: make distcheck - run: make distcheck diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index e8bd8ae..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,74 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ "main" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "main" ] - schedule: - - cron: '27 12 * * 4' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'cpp' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹ️ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" diff --git a/main/Maps.exe b/main/Maps.exe new file mode 100644 index 0000000..371ce60 Binary files /dev/null and b/main/Maps.exe differ diff --git a/main/README.md b/main/README.md new file mode 100644 index 0000000..564b7a0 --- /dev/null +++ b/main/README.md @@ -0,0 +1,90 @@ +# 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)。 + +Because the window size is limited, the pop-up version is introduced. Please refer to pop window version. + +因为窗口大小受限,所以推出了弹窗版本,请看pop-window-version。 + +## 版本 + +### V1.0 +This is a new Sandbox game. You can create or destroy rocks here, and you can walk freely. More functions are under development. + +这是一个新的沙盒游戏。你在这里可以创建或销毁岩石,也可以自由行走。更多功能开发中。 + +### V1.1 +The new portal function can easily reach remote places. + +新增传送门功能,可以方便地到达遥远之地。 + +### V1.2 +Added the function of importing and exporting documents. + +新增导入导出文档功能。 + +### V1.3.A + +Add small balls; Discard the archive function and stop providing it until the bug is fixed. + +新增小球;弃用存档功能,在修复好bug之前不再提供。 + +### V1.3.B + +Fix the bug that the ball does not update, and make changes to the screen related help. + +修复小球不更新的bug,并对屏幕相关帮助作出更改。 + +### V2.0 + +New eggs. Please explore or consult the code yourself. + +新增彩蛋。请自行探索或查阅代码。 + +### V2.1.0 + +Expand the egg of the previous version and add new achievements. Add language menu option. + +对上一版本的彩蛋进行扩充,新增成就。新增语言菜单选项。 + +#### V2.1.1 + +Optimization of some details. + +一些细节的优化。 + +#### V2.1.2 + +Optimization of some details. + +一些细节的优化。 + +#### 2022/11/8: + +合并pop-window-version为main分支。 + +Merge pop-window-version into main branch. + +### V2.2.0 + +New mode settings: normal mode and developer mode. + +新增模式设置:普通模式和开发者模式。 + +#### V2.2.1 + +1. New mode setting: Hell mode. + +2. Functional comments are provided for part of the code. + +1、新增模式设置:地狱模式。 + +2、为部分代码提供了功能注释。 + +#### V2.2.2 + +Modification of some details. + +一些细节的修改。 \ No newline at end of file diff --git a/main/defines/Eggs.cpp b/main/defines/Eggs.cpp new file mode 100644 index 0000000..e92efc1 --- /dev/null +++ b/main/defines/Eggs.cpp @@ -0,0 +1,93 @@ +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("CLS"); + 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("ϲصIJʵ\n˺ţc_cpp_aUID346332\n"); + } else if(s=="Snake"){ + ::print("̰ϷС\n"); + Sleep(1000);//Ժٲ + ::print("ʧܣ\n"); + } else{ + ::print("ԲIJκָ\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); + } +} + diff --git a/main/defines/Eggs.h b/main/defines/Eggs.h new file mode 100644 index 0000000..e10386d --- /dev/null +++ b/main/defines/Eggs.h @@ -0,0 +1,27 @@ +#ifndef EGGS_H_ +#define EGGS_H_ +//include STL +//׼ +#include +#include +//include custom library +//Զ +#include "def" +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/main/defines/Map.cpp b/main/defines/Map.cpp new file mode 100644 index 0000000..19a33ea --- /dev/null +++ b/main/defines/Map.cpp @@ -0,0 +1,97 @@ +void Map::print(int x,int y){ + 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; + } + if(::mode!=infernal || a[i][j]){ + putchar(print_c[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; + } + if(::mode!=infernal || a[i][j]){ + putchar(print_c[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; + } + if(::mode!=infernal || a[i][j]){ + putchar(print_c[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; + } + if(::mode!=infernal || a[i][j]){ + putchar(print_c[a[i][j]]); + } + } + putchar('\n'); + } + } + if(::mode==debugger){ + string contents="pos=("+to_string(x)+","+to_string(y)+")"; + gotoxy(0,COLS-contents.length()); + 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/main/defines/Map.h b/main/defines/Map.h new file mode 100644 index 0000000..b6b59e1 --- /dev/null +++ b/main/defines/Map.h @@ -0,0 +1,23 @@ +#ifndef MAP_H_ +#define MAP_H_ +//include STL +//׼ +#include +#include +//include custom library +//Զ +#include "def" +using namespace std; +class Map{ + private: + map> a; + int downx=0,righty=0; + public: + void print(int,int); + void change(int,int,int); + bool issave(int,int); +// void imports(); +// void save(); + map operator[](const int i); +}; +#endif diff --git a/main/defines/People.cpp b/main/defines/People.cpp new file mode 100644 index 0000000..0fd9e02 --- /dev/null +++ b/main/defines/People.cpp @@ -0,0 +1,174 @@ +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=getch(); + 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("CLS"); + 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); + create_door_helper(); + input=getch(); + 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("CLS"); + set_lang(); + break; + case 'T':case 't': + system("CLS"); + 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); +} +//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(); +//} diff --git a/main/defines/People.h b/main/defines/People.h new file mode 100644 index 0000000..7e86850 --- /dev/null +++ b/main/defines/People.h @@ -0,0 +1,45 @@ +#ifndef PEOPLE_H_ +#define PEOPLE_H_ +//include STL +//׼ +#include +#include +//include custom library +//Զ +#include "def" +#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; + } +// void save(Map &); +// void imports(Map &); +}; +const People::node People::default_node={-1,-1}; +#endif diff --git a/main/defines/def b/main/defines/def new file mode 100644 index 0000000..278d943 --- /dev/null +++ b/main/defines/def @@ -0,0 +1,51 @@ +/* + * ߣ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 +const int COLS=100,LINES=50;//ϷĴڴС +const int ADD_COLS=20,ADD_LINE=10;//ɾ͵ڴС +const int MODE_COUNT=3;//ģʽ +const char SAVE_NAME[]="data.mymap";//ļδʵװ +const int EGG_POS[3][10][2]={{5,5},{10,10},{2,2}};//EGG_POS[language][egg_number]={x,y} +enum{//ͼķ + defaults,//Ĭ + ups,// + downs,// + lefts,// + rights// +}; +enum{//ͼĻԪ + floor,//յأĬϣ + rock,//ʯ + door,// + ball//С +}; +enum{//Ϸ + unable,//δ壨Ĭϣ + Chinese,// + English//Ӣ +}; +enum{//ʵ + empty_egg, //ղʵĬϣûвʵ + CHI_egg_1,//IJʵ1 + UNABLE_egg_1//[δ]ʵ1 +}; +enum{//Ϸģʽ + normal,//Ĭϣ + debugger,//ģʽ + infernal//ģʽ +}; +std::map print_c={//ӦԪʾʲô + {floor,' '}, + {rock,'-'}, + {door,'@'}, + {ball,'o'} +}; +#endif diff --git a/main/defines/help_func.cpp b/main/defines/help_func.cpp new file mode 100644 index 0000000..7eb7e7c --- /dev/null +++ b/main/defines/help_func.cpp @@ -0,0 +1,27 @@ +namespace{ + using namespace std; + void print(const string s){ + for(auto len=s.length(),i=0ULL;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; + } +} + diff --git a/main/defines/help_func.h b/main/defines/help_func.h new file mode 100644 index 0000000..8d81036 --- /dev/null +++ b/main/defines/help_func.h @@ -0,0 +1,15 @@ +#ifndef HELP_FUNC_H_H_ +#define HELP_FUNC_H_H_ +//include STL +//׼ +#include +#include +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); +} +#endif diff --git a/main/defines/init.cpp b/main/defines/init.cpp new file mode 100644 index 0000000..8cc3a80 --- /dev/null +++ b/main/defines/init.cpp @@ -0,0 +1,150 @@ +//namespace{ +// int lang=unable; +//} +void set_parameters(){ + system("title ҵĵͼ"); + system(("mode "+to_string(COLS)+","+to_string(LINES+ADD_LINE)).c_str()); +} +void set_lang(){ + system("CLS"); + ::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=getch(); + 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=getch(); +// if(ifimport=='y'){ +// p.imports(h); +// } + cout << "˹ʱȱ\n"; + getch(); + system("CLS"); + } 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"; + getch(); + system("CLS"); + } + system("CLS"); +} +void screen_helper(){ + using namespace std; + if(lang==Chinese){ + //language:Chinese + //ԣ + cout << "\nH\nTá" << endl; + } else if(lang==English){ + //language:English + //ԣӢ + cout << "Press 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=getch(); + 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"; + } +} +const int &get_lang(){ + return ::lang; +} +void set_lang(const int x){ + ::lang=x; +} +void settings(){ + int choose; + do{ + system("CLS"); + if(lang==Chinese){ + //language:Chinese + //ԣ + cout << "ģʽ\n< "; + if(::mode==normal){ + cout << "ͨģʽ " << ' ' << " >"; + } else if(::mode==debugger){ + cout << "ģʽ >"; + } else{ + cout << "ģʽ " << ' ' << " >"; + } + cout << "\nq˳"; + } else if(lang==English){ + //language:English + //ԣӢ + cout << "pattern:\n< "; + if(::mode==normal){ + cout << ' ' << "Normal mode" << ' ' << ' ' << " >"; + } else if(::mode==debugger){ + cout << "Developer mode >"; + } else{ + cout << "Infernal mode" << ' ' << " >"; + } + cout << "\nPress the q key to exit."; + } + choose=getch(); + if(choose==224){ + choose=getch(); + } + 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'); +} diff --git a/main/defines/init.h b/main/defines/init.h new file mode 100644 index 0000000..032e4e0 --- /dev/null +++ b/main/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" +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("CLS"); + set_import(p,h); +} +const int &get_lang(); +void set_lang(const int); +void settings(); +#endif diff --git a/main/gmon.out b/main/gmon.out new file mode 100644 index 0000000..2c90a58 Binary files /dev/null and b/main/gmon.out differ diff --git a/main/main.cpp b/main/main.cpp new file mode 100644 index 0000000..44f0838 --- /dev/null +++ b/main/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" +#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) + Sleep(10);//Ϸˢʱ + p.set_f(G,egg);//(input) + egg.check_run(get_lang(),p,G);//Ƿ񴥷ʵ(Check whether the egg is triggered) + } + return 0; +} + diff --git a/main/main.exe b/main/main.exe new file mode 100644 index 0000000..1b32673 Binary files /dev/null and b/main/main.exe differ