Skip to content

Commit 85c2895

Browse files
authored
小更新
又是修复bug!不过现在加进来了及时保存后可能会比较卡。想要运行流畅(其实也没好到哪里去)的可以注释掉保存那一条语句后重编译,按esc保存并退出。
1 parent 25504e9 commit 85c2895

File tree

10 files changed

+49
-23
lines changed

10 files changed

+49
-23
lines changed

MapReader.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ int main(int argc,char ** argv){
2525
People p;
2626
Egg egg;
2727
Screen screen(egg,G,p,false,argc,argv);
28-
// init(p,G,egg,argc,argv);//调用初始化函数(Call initialization function)
28+
//init(p,G,egg,argc,argv);//调用初始化函数(Call initialization function)
2929
//游戏循环(Game cycle)
3030
//游戏的刷新速度约为100次/秒(Running speed of the game is about 100 ticks/second)
3131
while(true){
32-
// save(p,G,egg);//保存游戏
32+
screen.save();//保存游戏
3333
egg.check_run(screen.get_data().lang,p,G);//检测是否触发彩蛋(Check whether the egg is triggered)
34+
::ShowCursor(false);
3435
G.print(p.get_pos().x,p.get_pos().y,p.get_movef(),screen);//输出(print)
3536
::screen_helper(screen.get_data().lang);//提供帮助(Help)
3637
if(egg.is_ach()) egg.print_ach();//如果触发了成就系统,就运行输出成就(If the achievement system is triggered, run the output achievement)

MapReader.exe

0 Bytes
Binary file not shown.

README-EN.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# My-Map
22

3-
## note
4-
5-
This version is for Windows only. Chinese output or comments may be garbled, so feedback or transcoding can be performed (code usage code: GB2312). You can also read README.md in [English](README-EN.md) or [Chinese](README.md). At present, the panel conversion has not been completed.
6-
73
## directory
84
- [note](#note)
95

106
- [instructions](#instructions)
117

128
- [version](#version)
139

14-
- [Discussion Channel](#Discussion-Channel)
10+
- [Discussion Channel](#Discussion Channel)
11+
12+
## note
13+
14+
This version is for Windows only. Chinese output or comments may be garbled, so feedback or transcoding can be performed (code usage code: GB2312). You can also read README.md in [English](README-EN.md) or [Chinese](README.md). At present, the panel conversion has not been completed.
1515

1616
## instructions
1717

@@ -31,7 +31,7 @@ Of course, you can also set modes, view help, and create archives. These parts a
3131

3232
#### V2.4.0
3333

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).
34+
1. A new folder 'example' has been added, where you can view examples of the 'mymap' file. We strongly recommend trying to pass the 'maze. mymap' level. This file utilizes some bugs, but I will make it a setting in future technical adjustments. You can wait for it!
3535

3636
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.
3737

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# My-Map
22

3-
## 注意事项
4-
5-
此版本只适用于Windows。中文的输出或注释可能出现乱码,可以进行反馈或转码(代码使用编码:GB2312)。你也可以选择阅读语言:[English](README-EN.md)[中文](README.md)。目前板式转换尚未完工。
6-
73
## 目录
84

95
- [注意事项](#注意事项)
@@ -14,6 +10,10 @@
1410

1511
- [讨论频道](#讨论频道)
1612

13+
## 注意事项
14+
15+
此版本只适用于Windows。中文的输出或注释可能出现乱码,可以进行反馈或转码(代码使用编码:GB2312)。你也可以选择阅读语言:[English](README-EN.md)[中文](README.md)。目前板式转换尚未完工。
16+
1717
## 游戏说明
1818

1919
游戏采用向控制台显示二维地图的形式。玩家显示为字符 `#`,并展示。玩家可以使用 `WASD` 键进行移动(玩过游戏的都知道我指的是什么,或者可以自行搜索),并可以在前进方向上创建以下物品(若已由物品,则会覆盖原有物品;编辑在只读模式`MapReader`下失效):
@@ -32,7 +32,7 @@
3232

3333
#### V2.4.0
3434

35-
1. 新增了一个文件夹`example`,您可以查看`mymap`文件示例(如果下载后直接双击打开,音乐可能会加载失败,我正在努力修复)。
35+
1. 新增了一个文件夹`example`,您可以查看`mymap`文件示例。强烈建议尝试通关 `maze.mymap`。这个文件利用了一些bug,不过我会在之后的技术性调整中将其变为一种设置。可以等待!
3636

3737
2. `init.h`被弃用,其功能被分解至`Screen.h``help_func.h`。如果接下来的时间内没有什么问题,我会将其移除。
3838

defines/People.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ void People::imports(istream &fin){
238238
break;
239239
} else{
240240
doors[xi][yi]=node({xv,yv});
241-
242241
}
243242
}
244243
}

defines/Screen.h

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class Screen{
3939
~Screen();
4040
Data &get_data(){return data;}
4141
void setting();
42+
void alert(const std::string &title,const std::string &content);
43+
void save();
4244
};
4345
#include "Map.h"
4446
#include "People.h"
@@ -75,8 +77,14 @@ Screen::Screen(Egg &_egg,Map &_m,People &_p,bool isedit,int argc,char ** argv):e
7577
title("MapReader[read only]");
7678
}
7779
set_length_width(COLS,LINES+ADD_LINE);
80+
string background_music_name=argv[0];
81+
while(background_music_name.back()!='\\'){
82+
background_music_name.pop_back();
83+
}
84+
background_music_name+="defines\\sound\\1st.mp3";
85+
// alert("提示","background_music_name="+background_music_name);
7886
system(("cd \""+std::string(_getcwd(NULL,0))+"\"").c_str());
79-
system("start \"\" \".\\defines\\sound\\1st.mp3\"");
87+
system(("start "+background_music_name).c_str());
8088
if(argc==1){
8189
data.savefile_name=SAVE_NAME;
8290
init_lang(data.lang);
@@ -104,12 +112,7 @@ Screen::Screen(Egg &_egg,Map &_m,People &_p,bool isedit,int argc,char ** argv):e
104112
clear();
105113
}
106114
Screen::~Screen(){
107-
std::ofstream fout(data.savefile_name);
108-
map.save(fout);
109-
people.save(fout);
110-
egg.save(fout);
111-
fout << data.mode << ' ' << data.lang << endl;
112-
fout.close();
115+
save();
113116
}
114117
void Screen::setting(){
115118
int choose;
@@ -148,4 +151,15 @@ void Screen::setting(){
148151
}
149152
} while(choose!='q' && choose!='Q');
150153
}
154+
void Screen::alert(const std::string &title,const std::string &content){
155+
MessageBox(NULL,content.c_str(),title.c_str(),MB_OK);
156+
}
157+
void Screen::save(){
158+
std::ofstream fout(data.savefile_name);
159+
map.save(fout);
160+
people.save(fout);
161+
egg.save(fout);
162+
fout << data.mode << ' ' << data.lang << endl;
163+
fout.close();
164+
}
151165
#endif

defines/def

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ enum{//游戏模式
4646
* 清一色模式:所有的东西(空地除外)都显示成-,让你猜。
4747
*/
4848
};
49+
enum{//键盘操作
50+
ESC_ASCII=27,
51+
DIRECT_ASCII=224,
52+
DIRECT_RIGHT_ASCII=77,
53+
DIRECT_LEFT_ASCII=75,
54+
KEY_UP='W',
55+
KEY_DOWN='A',
56+
KEY_LEFT='S',
57+
KEY_RIGHT='D'
58+
};
4959
std::unordered_map<std::size_t,char> print_c={//对应元素显示成什么样
5060
{floors,' '},
5161
{rock,'-'},

example/maze.mymap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@
495495
97 98 20 91
496496
98 80 29 83
497497
99 90 10 41
498+
99 99 101 101
498499
-1 -1 -1 -1
499500
0
500501
0

main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ int main(int argc,char ** argv){
2525
People p;
2626
Egg egg;
2727
Screen screen(egg,G,p,true,argc,argv);
28-
// init(p,G,egg,argc,argv);//调用初始化函数(Call initialization function)
28+
//init(p,G,egg,argc,argv);//调用初始化函数(Call initialization function)
2929
//游戏循环(Game cycle)
3030
//游戏的刷新速度约为100次/秒(Running speed of the game is about 100 ticks/second)
3131
while(true){
32-
// save(p,G,egg);//保存游戏
32+
screen.save();//保存游戏
3333
egg.check_run(screen.get_data().lang,p,G);//检测是否触发彩蛋(Check whether the egg is triggered)
34+
::ShowCursor(false);
3435
G.print(p.get_pos().x,p.get_pos().y,p.get_movef(),screen);//输出(print)
3536
::screen_helper(screen.get_data().lang);//提供帮助(Help)
3637
if(egg.is_ach()) egg.print_ach();//如果触发了成就系统,就运行输出成就(If the achievement system is triggered, run the output achievement)

main.exe

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)