Skip to content

Commit 060535b

Browse files
authored
修复小bug
现在如果你想保存并退出游戏,请按Esc键。否则直接退出不会保存所做的更改。在更久之前,你所做的更改并不会被保存。
1 parent b15c1a3 commit 060535b

File tree

6 files changed

+11
-8
lines changed

6 files changed

+11
-8
lines changed

MapReader.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ int main(int argc,char ** argv){
3535
::screen_helper(screen.get_data().lang);//提供帮助(Help)
3636
if(egg.is_ach()) egg.print_ach();//如果触发了成就系统,就运行输出成就(If the achievement system is triggered, run the output achievement)
3737
Sleep(10);//游戏的刷新时间
38-
p.move(G,egg,screen);//输入(input)
38+
char ch=getch();
39+
if(ch==27) break;
40+
p.move(G,egg,screen,ch);//输入(input)
3941
}
4042
return 0;
4143
}

MapReader.exe

0 Bytes
Binary file not shown.

defines/People.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class People{
3434
const int back(const int &);
3535
public:
3636
People(bool _edit=true):canedit(_edit),move_f(defaults),pos({1,1}){}
37-
void move(Map &,Egg &,Screen &);
37+
void move(Map &h,Egg &egg,Screen &screen,const char &command);
3838
inline const node &at(int x,int y){
3939
return doors[x][y];
4040
}
@@ -95,13 +95,12 @@ const int People::back(const int &func){
9595
}
9696
return func;
9797
}
98-
void People::move(Map &h,Egg &egg,Screen &screen){
98+
void People::move(Map &h,Egg &egg,Screen &screen,const char &command){
9999
if(pos.x<=0 || pos.y<=0) egg.set_ach(8,1);
100100
if(egg[8] && pos.y>0 && pos.x>0){
101101
egg.set_ach(9,1);
102102
}
103-
int a=getch();
104-
switch(a){
103+
switch(command){
105104
case 'W':case 'w':
106105
if(!h.issave(pos.x-1,pos.y)) break;
107106
if(pos.x>1){
@@ -140,7 +139,7 @@ void People::move(Map &h,Egg &egg,Screen &screen){
140139
break;
141140
}
142141
if(canedit){
143-
switch(a){
142+
switch(command){
144143
case '1':
145144
{
146145
auto tmp=check_xy(pos,move_f);

example/maze.mymap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@
395395
100 99 1
396396
100 100 1
397397
-1 -1 -1
398-
8 23 2
398+
2 2 0
399399
3 13 30 26
400400
3 57 78 84
401401
6 70 30 54

main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ int main(int argc,char ** argv){
3535
::screen_helper(screen.get_data().lang);//提供帮助(Help)
3636
if(egg.is_ach()) egg.print_ach();//如果触发了成就系统,就运行输出成就(If the achievement system is triggered, run the output achievement)
3737
Sleep(10);//游戏的刷新时间
38-
p.move(G,egg,screen);//输入(input)
38+
char ch=getch();
39+
if(ch==27) break;
40+
p.move(G,egg,screen,ch);//输入(input)
3941
}
4042
return 0;
4143
}

main.exe

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)