Skip to content

Commit b15c1a3

Browse files
authored
终于更新了!
我知道你们很急,但别急,我更急。改bug让我筋疲力尽的。
1 parent b71da99 commit b15c1a3

File tree

15 files changed

+787
-61
lines changed

15 files changed

+787
-61
lines changed

MapReader.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
22
* 作者:c-cpp-a(Github)
3-
* 最近更新:2023/5/12
3+
* 最近更新:2023/5/21
44
* 功能简述:这是整个游戏的主体部分,负责运行游戏。
55
*/
66
/*
77
* Author: c-cpp-a(Github)
8-
* Last updated: 2023/5/12
8+
* Last updated: 2023/5/21
99
* Function description: This is the main part of the whole game, responsible for running the game.
1010
*/
1111
//include STL
@@ -22,21 +22,20 @@ int main(int argc,char ** argv){
2222
//Instantiate Object
2323
//实例化对象
2424
Map G;
25-
People p(false);
25+
People p;
2626
Egg egg;
27-
system(("cd \""+string(_getcwd(NULL,0))+"\"").c_str());
28-
system("start \"\" \".\\defines\\sound\\1st.mp3\"");
29-
init(p,G,egg,argc,argv);//调用初始化函数(Call initialization function)
27+
Screen screen(egg,G,p,false,argc,argv);
28+
// init(p,G,egg,argc,argv);//调用初始化函数(Call initialization function)
3029
//游戏循环(Game cycle)
3130
//游戏的刷新速度约为100次/秒(Running speed of the game is about 100 ticks/second)
3231
while(true){
33-
save(p,G,egg);//保存游戏
34-
egg.check_run(::lang,p,G);//检测是否触发彩蛋(Check whether the egg is triggered)
35-
G.print(p.get_pos().x,p.get_pos().y,p.get_movef());//输出(print)
36-
screen_helper();//提供帮助(Help)
32+
// save(p,G,egg);//保存游戏
33+
egg.check_run(screen.get_data().lang,p,G);//检测是否触发彩蛋(Check whether the egg is triggered)
34+
G.print(p.get_pos().x,p.get_pos().y,p.get_movef(),screen);//输出(print)
35+
::screen_helper(screen.get_data().lang);//提供帮助(Help)
3736
if(egg.is_ach()) egg.print_ach();//如果触发了成就系统,就运行输出成就(If the achievement system is triggered, run the output achievement)
3837
Sleep(10);//游戏的刷新时间
39-
p.set_f(G,egg);//输入(input)
38+
p.move(G,egg,screen);//输入(input)
4039
}
4140
return 0;
4241
}

MapReader.exe

-1.2 MB
Binary file not shown.

README-EN.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ Of course, you can also set modes, view help, and create archives. These parts a
2727

2828
## version
2929

30+
### V2.4
31+
32+
#### V2.4.0
33+
34+
1. A new folder 'example' has been added, where you can view the 'mymap' file example (if you double-click to open it after downloading, the music may fail to load, and I am working hard to fix it).
35+
36+
2. 'init. h' has been deprecated and its functionality has been decomposed into 'Screen. h' and 'help'_ func.h`。 If there are no issues in the future, I will remove them.
37+
3038
### V2.3
3139

3240
#### V2.3.8

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828

2929
## 版本
3030

31+
### V2.4
32+
33+
#### V2.4.0
34+
35+
1. 新增了一个文件夹`example`,您可以查看`mymap`文件示例(如果下载后直接双击打开,音乐可能会加载失败,我正在努力修复)。
36+
37+
2. `init.h`被弃用,其功能被分解至`Screen.h``help_func.h`。如果接下来的时间内没有什么问题,我会将其移除。
38+
3139
### V2.3
3240

3341
#### V2.3.8
@@ -144,15 +152,15 @@ New eggs. Please explore or consult the code yourself.
144152

145153
#### V1.3.1
146154

147-
Add small balls; Discard the archive function and stop providing it until the bug is fixed.
155+
Fix the bug that the ball does not update, and make changes to the screen related help.
148156

149-
新增小球;弃用存档功能,在修复好bug之前不再提供
157+
修复小球不更新的bug,并对屏幕相关帮助作出更改
150158

151159
#### V1.3.0
152160

153-
Fix the bug that the ball does not update, and make changes to the screen related help.
161+
Add small balls; Discard the archive function and stop providing it until the bug is fixed.
154162

155-
修复小球不更新的bug,并对屏幕相关帮助作出更改
163+
新增小球;弃用存档功能,在修复好bug之前不再提供
156164

157165
### V1.2
158166

defines/Eggs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class Egg{
3232
#include "def"
3333
#include "Map.h"
3434
#include "People.h"
35+
#include "help_func.h"
3536
int Egg::isegg(const int &lang,People &p,Map &h){
3637
if(lang==English &&
3738
h[EGG_POS[English][0][0]][EGG_POS[English][0][1]]==rock){

defines/Map.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,30 @@
1010
//include custom library
1111
//导入自定义库
1212
using namespace std;
13+
class Screen;
1314
class Map{
1415
private:
1516
map<int,map<int,int>> a;
1617
public:
17-
void print(const int &,const int &,const int &);
18+
void print(const int &,const int &,const int &,Screen &);
1819
void change(int,int,int);
1920
bool issave(int,int);
2021
void imports(ifstream &);
2122
void save(ofstream &);
2223
map<int,int> operator[](const int i);
2324
};
25+
#include "Screen.h"
2426
#include "help_func.h"
25-
void Map::print(const int &x,const int &y,const int &direct){
26-
gotoxy(0,0);
27+
void Map::print(const int &x,const int &y,const int &direct,Screen &screen){
28+
::gotoxy(0,0);
2729
if(x>=COLS/2 && y>=LINES/2){
2830
for(int i=x-LINES/2+1;i<=x+LINES/2;i++){
2931
for(int j=y-COLS/2+1;j<=y+COLS/2;j++){
3032
if(i==x && j==y){
31-
putchar('#');
33+
::putchar('#');
3234
continue;
3335
}
34-
map_print(a[i][j]);
36+
::map_print(a[i][j],screen);
3537
}
3638
putchar('\n');
3739
}
@@ -42,7 +44,7 @@ void Map::print(const int &x,const int &y,const int &direct){
4244
putchar('#');
4345
continue;
4446
}
45-
map_print(a[i][j]);
47+
::map_print(a[i][j],screen);
4648
}
4749
putchar('\n');
4850
}
@@ -53,7 +55,7 @@ void Map::print(const int &x,const int &y,const int &direct){
5355
putchar('#');
5456
continue;
5557
}
56-
map_print(a[i][j]);
58+
::map_print(a[i][j],screen);
5759
}
5860
putchar('\n');
5961
}
@@ -64,13 +66,13 @@ void Map::print(const int &x,const int &y,const int &direct){
6466
putchar('#');
6567
continue;
6668
}
67-
map_print(a[i][j]);
69+
map_print(a[i][j],screen);
6870
}
6971
putchar('\n');
7072
}
7173
}
72-
if(::mode==debugger){
73-
string contents="pos=("+to_string(x)+","+to_string(y)+"),direct="+direct_content[::lang][direct];
74+
if(screen.get_data().mode==debugger){
75+
string contents="pos=("+to_string(x)+","+to_string(y)+"),direct="+direct_content[screen.get_data().lang][direct];
7476
gotoxy(0,COLS);
7577
cout << contents;
7678
}

defines/People.h

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using namespace std;
1212
class Map;
1313
class Egg;
14+
class Screen;
1415
class People{
1516
public:
1617
friend class Egg;
@@ -33,8 +34,7 @@ class People{
3334
const int back(const int &);
3435
public:
3536
People(bool _edit=true):canedit(_edit),move_f(defaults),pos({1,1}){}
36-
void set_f(Map &,Egg &);
37-
void put_xy(Map &);
37+
void move(Map &,Egg &,Screen &);
3838
inline const node &at(int x,int y){
3939
return doors[x][y];
4040
}
@@ -52,7 +52,8 @@ class People{
5252
};
5353
#include "Map.h"
5454
#include "Eggs.h"
55-
#include "init.h"
55+
//#include "init.h"
56+
#include "Screen.h"
5657
const People::node People::default_node={-1,-1};
5758
bool People::node::operator!=(const People::node a) const{
5859
return x!=a.x || y!=a.y;
@@ -94,7 +95,7 @@ const int People::back(const int &func){
9495
}
9596
return func;
9697
}
97-
void People::set_f(Map &h,Egg &egg){
98+
void People::move(Map &h,Egg &egg,Screen &screen){
9899
if(pos.x<=0 || pos.y<=0) egg.set_ach(8,1);
99100
if(egg[8] && pos.y>0 && pos.x>0){
100101
egg.set_ach(9,1);
@@ -126,16 +127,16 @@ void People::set_f(Map &h,Egg &egg){
126127
move_f=rights;
127128
break;
128129
case 'H':case 'h':
129-
system("CLS");
130-
print_helper();
130+
screen.clear();
131+
print_helper(screen);
131132
break;
132133
case 'L':case 'l':
133-
system("CLS");
134-
set_lang();
134+
screen.clear();
135+
screen.init_lang(screen.get_data().lang);
135136
break;
136137
case 'T':case 't':
137-
system("CLS");
138-
settings();
138+
screen.clear();
139+
screen.setting();
139140
break;
140141
}
141142
if(canedit){
@@ -162,8 +163,8 @@ void People::set_f(Map &h,Egg &egg){
162163
auto tmp=check_xy(pos,move_f),tmp2=tmp;
163164
h.change(tmp.x,tmp.y,door);
164165
while(input!=' '){
165-
h.print(tmp2.x,tmp2.y,move_f);
166-
create_door_helper();
166+
h.print(tmp2.x,tmp2.y,move_f,screen);
167+
create_door_helper(screen.get_data().lang);
167168
input=getch();
168169
switch(input){
169170
case 'W':case 'w':
@@ -219,9 +220,6 @@ void People::set_f(Map &h,Egg &egg){
219220
}
220221
}
221222
}
222-
void People::put_xy(Map &h){
223-
h.print(pos.x,pos.y,move_f);
224-
}
225223
void People::save(ostream &fout){
226224
fout << pos.x << ' ' << pos.y << ' ' << move_f << endl;
227225
for(auto it=doors.begin();it!=doors.end();++it){
@@ -241,6 +239,7 @@ void People::imports(istream &fin){
241239
break;
242240
} else{
243241
doors[xi][yi]=node({xv,yv});
242+
244243
}
245244
}
246245
}

0 commit comments

Comments
 (0)