Skip to content

Commit 7385e80

Browse files
authored
更新见说明
1 parent de19159 commit 7385e80

File tree

12 files changed

+151
-84
lines changed

12 files changed

+151
-84
lines changed

MapReader.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* 作者:c-cpp-a(Github)
3+
* 最近更新:2023/5/12
4+
* 功能简述:这是整个游戏的主体部分,负责运行游戏。
5+
*/
6+
/*
7+
* Author: c-cpp-a(Github)
8+
* Last updated: 2023/5/12
9+
* Function description: This is the main part of the whole game, responsible for running the game.
10+
*/
11+
//include STL
12+
//导入标准库
13+
#include<windows.h>
14+
#include<stdlib.h>
15+
#include<string>
16+
//include custom library
17+
//导入自定义库
18+
#include "include_files.h"
19+
using namespace std;
20+
int main(int argc,char ** argv){
21+
//Instantiate Object
22+
//实例化对象
23+
Map G;
24+
People p(false);
25+
Egg egg;
26+
AudioClip musicplayer;
27+
init(p,G,egg,argc,argv);//调用初始化函数(Call initialization function)
28+
// cout << (musicplayer.load("defines/music/1st.mp3")?"Load sucessfully":"Load fail");
29+
// system("pause");
30+
//游戏循环(Game cycle)
31+
//游戏的刷新速度约为100次/秒(Running speed of the game is about 100 ticks/second)
32+
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)
37+
if(egg.is_ach()) egg.print_ach();//如果触发了成就系统,就运行输出成就(If the achievement system is triggered, run the output achievement)
38+
Sleep(10);//游戏的刷新时间
39+
p.set_f(G,egg);//输入(input)
40+
}
41+
return 0;
42+
}
43+

MapReader.exe

2.2 MB
Binary file not shown.

README-EN.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This version is for Windows only. Chinese output or comments may be garbled, so
1515

1616
## instructions
1717

18-
The game adopts the form of displaying a two-dimensional map to the console. The player displays the character '#' and displays it. Players can use the 'WASD' button to move (those who have played the game know what I mean, or they can search for it themselves), and can create the following items in the forward direction (if they are already items, they will overwrite the original items):
18+
The game adopts the form of displaying a two-dimensional map to the console. The player displays the character '#' and displays it. Players can use the 'WASD' button to move (those who have played the game know what I mean, or they can search for it themselves), and can create the following items in the forward direction (If it is already an item, it will overwrite the original item; Editing is invalid in read-only mode 'MapReader'):
1919

2020
- Wall, press the '2' key to create it. The wall displays as' - '. Players cannot move through walls. This means you can build a maze now!
2121
- Portal, press the '3' key to create. The portal is displayed as' @ '. If players move through the portal, they will be teleported to a specific location (designated by themselves). Of course, ignore what item is on it (note, this is the key to egg coloring!)
@@ -29,6 +29,12 @@ Of course, you can also set modes, view help, and create archives. These parts a
2929

3030
### V2.3
3131

32+
#### V2.3.7
33+
34+
1. Fixed some minor bugs.
35+
36+
2. You can see that I have added a new file called 'MapReader.cpp' and the corresponding 'exe' file. This can be used for just manipulating games (without editing). That is to say, you can create a decryption game and share the saved file for others to use to operate the game. You don't have to worry about others cheating by modifying levels. The titles of the two files are not the same, so you can easily distinguish between edit mode and read-only mode.
37+
3238
#### V2.3.6
3339

3440
1. Add two new achievements (extremely difficult to obtain)!

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
## 游戏说明
1818

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

2121
- 墙壁,按 `2` 键创建。墙壁显示为 `-`。玩家并不能通过移动来通过墙壁。这意味着你可以构筑一个迷宫了!
2222
- 传送门,按 `3` 键创建。传送门显示为 `@`。玩家如果通过移动来通过传送门的话,你会被传送到某一地点(自己指定)。当然无视上面是什么物品(注意,这是彩蛋的关键!)
@@ -30,6 +30,12 @@
3030

3131
### V2.3
3232

33+
#### V2.3.7
34+
35+
1. 修复了一些小bug。
36+
37+
2. 您可以看到我新添加了一个文件`MapReader.cpp`和相应的`exe`文件。这可以用来只是操作游戏(并不编辑)。也就是说,您可以制作解密游戏,并分享存档,让其他人用这个文件来操作游戏。您不必担心别人用修改关卡的方法作弊。两个文件的标题并不相同,您很容易就能区分哪个是编辑模式,哪个是只读模式。
38+
3339
#### V2.3.6
3440

3541
1. 新增两个成就(极难获得)!

defines/Eggs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Egg{
1515
bool has_ach;
1616
unsigned int achs;
1717
public:
18-
Egg():achs(0),has_ach(false){}
18+
Egg():has_ach(false),achs(0){}
1919
int isegg(const int &,People &,Map &);
2020
void check_run(const int &,People &,Map &);
2121
void print_ach();

defines/Map.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ class Map{
1414
private:
1515
map<int,map<int,int>> a;
1616
public:
17-
void print(int,int,const int &);
17+
void print(const int &,const int &,const int &);
1818
void change(int,int,int);
1919
bool issave(int,int);
2020
void imports(ifstream &);
2121
void save(ofstream &);
2222
map<int,int> operator[](const int i);
2323
};
2424
#include "help_func.h"
25-
void Map::print(int x,int y,const int &direct){
25+
void Map::print(const int &x,const int &y,const int &direct){
2626
gotoxy(0,0);
2727
if(x>=COLS/2 && y>=LINES/2){
2828
for(int i=x-LINES/2+1;i<=x+LINES/2;i++){

defines/People.h

Lines changed: 70 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,30 @@ class People{
2525
};
2626
static const node default_node;
2727
private:
28-
int move_f=defaults,lang;
28+
bool canedit;
29+
int move_f=defaults;
2930
node pos;
3031
map<int,map<int,node> > doors;
3132
node check_xy(node x,const int &func);
3233
const int back(const int &);
3334
public:
34-
People():move_f(defaults),lang(unable),pos({1,1}){}
35+
People(bool _edit=true):canedit(_edit),move_f(defaults),pos({1,1}){}
3536
void set_f(Map &,Egg &);
3637
void put_xy(Map &);
37-
inline const node at(int x,int y){
38+
inline const node &at(int x,int y){
3839
return doors[x][y];
3940
}
40-
inline const node get_pos(){
41+
inline const node &get_pos() const{
4142
return pos;
4243
}
43-
inline const int &get_movef(){
44+
inline const int &get_movef() const{
4445
return move_f;
4546
}
46-
void save(ofstream &);
47-
void imports(ifstream &);
47+
inline const bool &edit() const{
48+
return canedit;
49+
}
50+
void save(ostream &);
51+
void imports(istream &);
4852
};
4953
#include "Map.h"
5054
#include "Eggs.h"
@@ -124,57 +128,6 @@ void People::set_f(Map &h,Egg &egg){
124128
case 'H':case 'h':
125129
system("CLS");
126130
print_helper();
127-
case '1':
128-
{
129-
auto tmp=check_xy(pos,move_f);
130-
h.change(tmp.x,tmp.y,floors);
131-
doors[tmp.x][tmp.y]=default_node;
132-
if(egg.is_ach()) egg.set_ach(0,1);
133-
}
134-
break;
135-
case '2':
136-
{
137-
auto tmp=check_xy(pos,move_f);
138-
h.change(tmp.x,tmp.y,rock);
139-
doors[tmp.x][tmp.y]=default_node;
140-
if(egg.is_ach()) egg.set_ach(1,1);
141-
}
142-
break;
143-
case '3':
144-
{
145-
int input=0;
146-
auto tmp=check_xy(pos,move_f),tmp2=tmp;
147-
h.change(tmp.x,tmp.y,door);
148-
while(input!=' '){
149-
h.print(tmp2.x,tmp2.y,move_f);
150-
create_door_helper();
151-
input=getch();
152-
switch(input){
153-
case 'W':case 'w':
154-
if(tmp2.x>1) tmp2.x--;
155-
break;
156-
case 'A':case 'a':
157-
if(tmp2.y>1) tmp2.y--;
158-
break;
159-
case 'S':case 's':
160-
tmp2.x++;
161-
break;
162-
case 'D':case 'd':
163-
tmp2.y++;
164-
break;
165-
}
166-
}
167-
doors[tmp.x][tmp.y]=tmp2;
168-
if(egg.is_ach()) egg.set_ach(2,1);
169-
}
170-
break;
171-
case '4':
172-
{
173-
auto tmp=check_xy(pos,move_f);
174-
h.change(tmp.x,tmp.y,ball);
175-
doors[tmp.x][tmp.y]=default_node;
176-
if(egg.is_ach()) egg.set_ach(3,1);
177-
}
178131
break;
179132
case 'L':case 'l':
180133
system("CLS");
@@ -184,8 +137,64 @@ void People::set_f(Map &h,Egg &egg){
184137
system("CLS");
185138
settings();
186139
break;
187-
188140
}
141+
if(canedit){
142+
switch(a){
143+
case '1':
144+
{
145+
auto tmp=check_xy(pos,move_f);
146+
h.change(tmp.x,tmp.y,floors);
147+
doors[tmp.x][tmp.y]=default_node;
148+
if(egg.is_ach()) egg.set_ach(0,1);
149+
}
150+
break;
151+
case '2':
152+
{
153+
auto tmp=check_xy(pos,move_f);
154+
h.change(tmp.x,tmp.y,rock);
155+
doors[tmp.x][tmp.y]=default_node;
156+
if(egg.is_ach()) egg.set_ach(1,1);
157+
}
158+
break;
159+
case '3':
160+
{
161+
int input=0;
162+
auto tmp=check_xy(pos,move_f),tmp2=tmp;
163+
h.change(tmp.x,tmp.y,door);
164+
while(input!=' '){
165+
h.print(tmp2.x,tmp2.y,move_f);
166+
create_door_helper();
167+
input=getch();
168+
switch(input){
169+
case 'W':case 'w':
170+
if(tmp2.x>1) tmp2.x--;
171+
break;
172+
case 'A':case 'a':
173+
if(tmp2.y>1) tmp2.y--;
174+
break;
175+
case 'S':case 's':
176+
tmp2.x++;
177+
break;
178+
case 'D':case 'd':
179+
tmp2.y++;
180+
break;
181+
}
182+
}
183+
doors[tmp.x][tmp.y]=tmp2;
184+
if(egg.is_ach()) egg.set_ach(2,1);
185+
}
186+
break;
187+
case '4':
188+
{
189+
auto tmp=check_xy(pos,move_f);
190+
h.change(tmp.x,tmp.y,ball);
191+
doors[tmp.x][tmp.y]=default_node;
192+
if(egg.is_ach()) egg.set_ach(3,1);
193+
}
194+
break;
195+
}
196+
}
197+
189198
if(doors[pos.x][pos.y]!=default_node){
190199
auto tmp=pos;
191200
pos.x=doors[tmp.x][tmp.y].x;
@@ -213,7 +222,7 @@ void People::set_f(Map &h,Egg &egg){
213222
void People::put_xy(Map &h){
214223
h.print(pos.x,pos.y,move_f);
215224
}
216-
void People::save(ofstream &fout){
225+
void People::save(ostream &fout){
217226
fout << pos.x << ' ' << pos.y << ' ' << move_f << endl;
218227
for(auto it=doors.begin();it!=doors.end();++it){
219228
for(auto itj=(it->second).begin();itj!=(it->second).end();++itj){
@@ -224,7 +233,7 @@ void People::save(ofstream &fout){
224233
}
225234
fout << "-1 -1 -1 -1 \n";
226235
}
227-
void People::imports(ifstream &fin){
236+
void People::imports(istream &fin){
228237
fin >> pos.x >> pos.y >> move_f;
229238
int xi,yi,xv,yv;
230239
while(fin >> xi >> yi >> xv >> yv){

defines/Screen.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ class Screen{
1010
Egg &egg;
1111
Map &map;
1212
People &people;
13-
HANDLE hins;
13+
HANDLE handle;
1414
void title(const std::string &s){
15-
15+
system(("title "+s).c_str());
1616
}
1717
public:
18-
Screen(Egg &_egg,Map &_m,People &_p):egg(_egg),map(_m),people(_p){
19-
hins=GetStdHandle(STD_OUTPUT_HANDLE);
20-
18+
Screen(Egg &_egg,Map &_m,People &_p,bool isedit):egg(_egg),map(_m),people(_p){
19+
handle=GetStdHandle(STD_OUTPUT_HANDLE);
20+
title("我的地图(My-Map)");
2121
}
2222
};
2323
#endif

defines/help_func.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//导入标准库
55
#include<string>
66
#include<windows.h>
7+
#include<conio.h>
78
#include<iostream>
89
#include "def"
910
namespace{

defines/init.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ void save(People &,Map &,Egg &,const char * name=SAVE_NAME);
2626
#include "People.h"
2727
#include "Map.h"
2828
#include "Eggs.h"
29-
void set_parameters(){
29+
void set_parameters(const bool &canedit){
3030
using namespace std;
3131
::ShowCursor(false);
32-
system("title 我的地图");
32+
if(canedit) system("title 我的地图(My-Map)");
33+
else system("title MapReader[read only]");
3334
system(("mode "+to_string(COLS)+","+to_string(LINES+ADD_LINE)).c_str());
3435
}
3536
void set_lang(){
@@ -144,10 +145,10 @@ void create_door_helper(){
144145
}
145146
}
146147
void init(People &p,Map &h,Egg &egg,int argc,char ** argv){
147-
set_parameters();
148+
set_parameters(p.edit());
148149
if(argc==1){
149150
set_lang();
150-
bool ifimport=set_import(p,h,egg);
151+
set_import(p,h,egg);
151152
system("CLS");
152153
} else{
153154
import(p,h,egg,argv[1]);

0 commit comments

Comments
 (0)