Skip to content

Commit b143984

Browse files
authored
更新见说明
外加修复若干bug
1 parent ee535ce commit b143984

File tree

11 files changed

+218
-16
lines changed

11 files changed

+218
-16
lines changed

README-EN.md

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

3+
## directory
4+
- [note](#note)
5+
6+
- [instructions](#instructions)
7+
8+
- [version](#version)
9+
10+
- [Discussion Channel](#Discussion Channel)
11+
312
## note
413

514
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.
@@ -20,9 +29,15 @@ Of course, you can also set modes, view help, and create archives. These parts a
2029

2130
### V2.3
2231

32+
#### V2.3.6
33+
34+
1. Add two new achievements (extremely difficult to obtain)!
35+
36+
2. Added a directory for 'README.md'.
37+
2338
#### V2.3.5
2439

25-
Archive updated again! Added language options. In addition, if you do not want to use the default archive location, you can also open the archive file using 'main.exe'.
40+
Archive updated again! Added language options. In addition, if you do not want to use the default archive location, you can also open the archive file with using 'main.exe'.
2641

2742
#### V2.3.4
2843

@@ -58,4 +73,10 @@ Slightly revised RENAME.md.
5873

5974
3. New mode: All in one mode.
6075

61-
--snip--
76+
--snip--
77+
78+
## Discussion Channel
79+
80+
[github link](https://github.com/c-cpp-a/My-Map/discussions) (github.com)
81+
82+
[luogu link](https://www.luogu.com.cn/blog/somebody66xyyd/my-map) (luogu.com.cn)

README.md

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

3+
## 目录
4+
5+
- [注意事项](#注意事项)
6+
7+
- [游戏说明](#游戏说明)
8+
9+
- [版本](#版本)
10+
11+
- [讨论频道](#讨论频道)
12+
313
## 注意事项
414

515
此版本只适用于Windows。中文的输出或注释可能出现乱码,可以进行反馈或转码(代码使用编码:GB2312)。你也可以选择阅读语言:[English](README-EN.md)[中文](README.md)。目前板式转换尚未完工。
@@ -20,9 +30,15 @@
2030

2131
### V2.3
2232

33+
#### V2.3.6
34+
35+
1. 新增两个成就(极难获得)!
36+
37+
2.`README.md`新增了目录。
38+
2339
#### V2.3.5
2440

25-
存档再次更新!添加了语言选项。此外,如果你不想使用默认的存档位置的话,也可以将存档文件使用`main.exe`打开
41+
存档再次更新!添加了语言选项。此外,如果你不想使用默认的存档位置的话,也可以将存档文件拖入`main.exe`中打开
2642

2743
#### V2.3.4
2844

@@ -149,8 +165,8 @@ This is a new Sandbox game. You can create or destroy rocks here, and you can wa
149165

150166
这是一个新的沙盒游戏。你在这里可以创建或销毁岩石,也可以自由行走。更多功能开发中。
151167

152-
# 讨论频道
168+
## 讨论频道
153169

154-
[discord链接 discord link](https://discord.gg/hK3P8YaJ) (discord.gg)
170+
[github链接](https://github.com/c-cpp-a/My-Map/discussions) (github.com)
155171

156-
[洛谷链接 luogu link](https://www.luogu.com.cn/blog/somebody66xyyd/my-map) luogu.com.cn)
172+
[洛谷链接](https://www.luogu.com.cn/blog/somebody66xyyd/my-map) (luogu.com.cn)

defines/Eggs.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ class Egg{
2222
void imports(ifstream &);
2323
void save(ofstream &);
2424
inline bool is_ach(){
25-
return achs!=0;
25+
return has_ach;
2626
}
2727
inline bool operator[](size_t i){
2828
return achs&(1<<i);
2929
}
30-
inline void set_ach(size_t i,bool value){
31-
achs|=(1<<i);
32-
}
30+
void set_ach(size_t i,bool value);
3331
};
3432
#include "def"
3533
#include "Map.h"
@@ -51,7 +49,8 @@ int Egg::isegg(const int &lang,People &p,Map &h){
5149
}
5250
void Egg::check_run(const int &lang,People &p,Map &h){
5351
system("CLS");
54-
switch(isegg(lang,p,h)){
52+
int get_egg=isegg(lang,p,h);
53+
switch(get_egg){
5554
case CHI_egg_1:
5655
{
5756
set_ach(6,1);
@@ -101,8 +100,8 @@ void Egg::check_run(const int &lang,People &p,Map &h){
101100
void Egg::print_ach(){
102101
auto y=0;
103102
y=ach_print("achievement",y);
104-
for(int i=0;i<8;i++){
105-
y=ach_print(achs_print[i],y);
103+
for(int i=0;i<10;i++){
104+
if((*this)[i]) y=ach_print(achs_print[i],y);
106105
}
107106
}
108107
void Egg::imports(ifstream &fin){
@@ -114,4 +113,7 @@ void Egg::save(ofstream &fout){
114113
fout << achs;
115114
fout << endl;
116115
}
116+
void Egg::set_ach(size_t i,bool value){
117+
achs|=(1<<i);
118+
}
117119
#endif

defines/People.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ const int People::back(const int &func){
9191
return func;
9292
}
9393
void People::set_f(Map &h,Egg &egg){
94+
if(pos.x<=0 || pos.y<=0) egg.set_ach(8,1);
95+
if(egg[8] && pos.y>0 && pos.x>0){
96+
egg.set_ach(9,1);
97+
}
9498
int a=getch();
9599
switch(a){
96100
case 'W':case 'w':

defines/Screen.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
#ifndef SCREEN_H_H
22
#define SCREEN_H_H
3+
#include<windows.h>
4+
#include<string>
5+
class Egg;
6+
class Map;
7+
class People;
38
class Screen{
4-
9+
private:
10+
Egg &egg;
11+
Map &map;
12+
People &people;
13+
HANDLE hins;
14+
void title(const std::string &s){
15+
16+
}
17+
public:
18+
Screen(Egg &_egg,Map &_m,People &_p):egg(_egg),map(_m),people(_p){
19+
hins=GetStdHandle(STD_OUTPUT_HANDLE);
20+
21+
}
522
};
623
#endif

defines/SoundPlayer.h

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
#ifndef SOUNDPLAYER_H_H
2+
#define SOUNDPLAYER_H_H
3+
#include<string>
4+
#include<Windows.h>
5+
#include<time.h>
6+
typedef int(__stdcall* w32mci)(const char*, char*, int, int);
7+
typedef int(__stdcall * w32mcierror)(int, char*, int);
8+
class Mci
9+
{
10+
private:
11+
HINSTANCE hins;
12+
w32mci wmci;
13+
w32mcierror wmcierror;
14+
public:
15+
Mci();
16+
~Mci();
17+
char buf[256];
18+
bool send(std::string command);//error return false
19+
};
20+
class AudioClip
21+
{
22+
private:
23+
Mci mci;
24+
std::string filename;
25+
std::string alias;
26+
int length_ms;
27+
public:
28+
AudioClip();
29+
~AudioClip();
30+
bool load(const std::string& _filename);
31+
bool play(int start_ms=0, int end_ms=-1);
32+
bool stop();
33+
bool pause();
34+
bool unpause();
35+
int milliseconds();
36+
};
37+
Mci::Mci()
38+
{
39+
HINSTANCE hins = LoadLibraryA("winmm.dll");
40+
wmci=(w32mci)GetProcAddress(hins, "mciSendStringA");
41+
wmcierror = (w32mcierror)GetProcAddress(hins, "mciGetErrorStringA");
42+
}
43+
Mci::~Mci()
44+
{
45+
FreeLibrary(hins);
46+
}
47+
bool Mci::send(std::string command)
48+
{
49+
int errcode = wmci(command.c_str(), buf, 254, 0);
50+
if (errcode)
51+
{
52+
wmcierror(errcode, buf, 254);
53+
return false;
54+
}
55+
return true;
56+
}
57+
AudioClip::AudioClip()
58+
{
59+
//do nothing
60+
}
61+
AudioClip::~AudioClip()
62+
{
63+
std::string cmd;
64+
cmd = "close " + alias;
65+
mci.send(cmd);
66+
}
67+
bool AudioClip::load(const std::string& _filename)
68+
{
69+
filename = _filename;
70+
for (unsigned int i = 0; i < filename.length(); i++)
71+
{
72+
if (filename[i] == '/')
73+
filename[i] = '\\';
74+
}
75+
alias = "mp3_";
76+
srand(time(NULL));
77+
char randstr[6];
78+
_itoa(rand() % 65536, randstr, 10);
79+
alias.append(randstr);
80+
std::string cmd;
81+
cmd = "open " + filename + " alias " + alias;
82+
if (mci.send(cmd) == false)
83+
return false;
84+
cmd = "set " + alias + " time format milliseconds";
85+
if (mci.send(cmd) == false)
86+
return false;
87+
cmd = "status " + alias + " length";
88+
if (mci.send(cmd) == false)
89+
return false;
90+
length_ms = atoi(mci.buf);
91+
return true;
92+
}
93+
bool AudioClip::play(int start_ms , int end_ms)
94+
{
95+
if (end_ms == -1) end_ms = length_ms;
96+
std::string cmd;
97+
char start_str[16], end_str[16];
98+
_itoa(start_ms, start_str,10);
99+
_itoa(end_ms, end_str, 10);
100+
cmd = "play " + alias+" from ";
101+
cmd.append(start_str);
102+
cmd.append(" to ");
103+
cmd.append(end_str);
104+
return mci.send(cmd);
105+
}
106+
bool AudioClip::stop()
107+
{
108+
std::string cmd;
109+
cmd = "stop "+alias;
110+
if (mci.send(cmd) == false)
111+
return false;
112+
cmd = "seek " + alias + " to start";
113+
if (mci.send(cmd) == false)
114+
return false;
115+
return true;
116+
}
117+
bool AudioClip::pause()
118+
{
119+
std::string cmd;
120+
cmd = "pause " + alias;
121+
if (mci.send(cmd) == false)
122+
return false;
123+
return true;
124+
}
125+
bool AudioClip::unpause()
126+
{
127+
std::string cmd;
128+
cmd = "resume " + alias;
129+
if (mci.send(cmd) == false)
130+
return false;
131+
return true;
132+
}
133+
int AudioClip::milliseconds()
134+
{
135+
return length_ms;
136+
}
137+
#endif

defines/def

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ const char achs_print[][64]={
7575
{"5.first access to the portal"},
7676
{"6.move your ball the first time."},
7777
{"7.found Chinese egg 1."},
78-
{"8.found [unable] Egg 1."}
78+
{"8.found [unable] Egg 1."},
79+
{"9.entered a place that should not have been entered."},
80+
{"10.entered the wrong place and returned to the original area."}
7981
};
8082
#endif

defines/sound/1st.mp3

1.46 MB
Binary file not shown.

include_files.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ class Egg;
1212
#include "defines/People.h"
1313
#include "defines/Eggs.h"
1414
#include "defines/init.h"
15+
#include "defines/SoundPlayer.h"

main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ int main(int argc,char ** argv){
2222
Map G;
2323
People p;
2424
Egg egg;
25+
// AudioClip musicplayer;
2526
init(p,G,egg,argc,argv);//调用初始化函数(Call initialization function)
27+
// musicplayer.load("./defines/music/1st.mp3");
28+
// musicplayer.play();
2629
//游戏循环(Game cycle)
2730
//游戏的刷新速度约为60次/秒(Running speed of the game is about 60ticks/second)
2831
while(true){
@@ -33,7 +36,6 @@ int main(int argc,char ** argv){
3336
Sleep(1000/60);//游戏的刷新时间
3437
p.set_f(G,egg);//输入(input)
3538
egg.check_run(::lang,p,G);//检测是否触发彩蛋(Check whether the egg is triggered)
36-
fflush(stdout);
3739
}
3840
return 0;
3941
}

0 commit comments

Comments
 (0)