-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGame.h
161 lines (130 loc) · 2.88 KB
/
Game.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
Game.h 游戏主要头文件,包含各个类的声明
by @WoodenStone @Mango-wen
*/
//防止多次调用
#pragma once
#include "maze.h"
constexpr auto MaxN = 150;
extern mouse_msg m_msg;
extern char ch_msg;
extern long long times, start_time;
//定义对话框位置相关参数
typedef struct {
int x;
int y;
int weight;
int height;
}msgBoxPosition;
//主要探索模式类
class CAdventure
{
public:
int single_pass, all_pass; //单关卡、总关卡
int x, y; //人物当前坐标
int flag[3][2600]; //迷宫中坐标与图节点编号关系记录
typedef struct
{
int Nv; /* 顶点数 */
int Ne; /* 边数 */
int des_x, des_y; //终点坐标
int size_n, size_m; //迷宫大小
int map[MaxN][MaxN]; //迷宫地图存储
int fmap[MaxN][MaxN]; /*辅助迷宫地图*/
int reg[2600][2600]; /* 邻接矩阵 */
int feg[2600][2600]; /*辅助邻接矩阵*/
}Map;
struct QueueNode {
/** 队列中存储的节点 */
int x;
int y;
};
Map maze;
bool visit[2500]; /*记录该点是否走过*/
union STAGE {
int num;
}Stage;
void man_Move();
void clear();
void CreateMaze(int x,int y);
int Check(int x, int y);
void dfs_search(int step);
void Connect(int x1, int y1, int x2, int y2);
void printQueueSteps(int rows, int cols, int num);
void solveByQueue(int rows, int cols, int num);
void SolveByStack(int rows, int cols, int num);
};
//按钮类
class CButton
{
public:
CButton() {}
~CButton() {}
void drawBackground();
void putButton_(int start_x, int start_y, int end_x, int end_y, char str_but[]);
int putMessageBox(msgBoxPosition msgPosition, wchar_t title[], wchar_t* text[], int g_num, int var);
bool putButton(int start_x, int start_y, char str_but[]);
bool ifClick(int xClick, int yClick, int xButton_start, int yButton_start, int xButton_finish, int yButton_finish);
};
//界面类
class CUI
{
public:
void mainMenu();
bool oneLevelClear();
void gameClear();
void gameHelp();
private:
CAdventure CAd;
};
//初始界面类
class CnewGameUI :public CUI
{
public:
void initialMenu();
};
//探索模式-森林stage
class CForest :public CAdventure, public CUI
{
public:
CForest() {}
~CForest() {}
void mainGame(); //模式核心
private:
void putRoom(); //绘制界面
void prim();//迷宫算法
};
//探索模式-沙漠stage
class CDesert :public CAdventure, public CUI
{
public:
CDesert() {}
~CDesert() {}
void mainGame(); //模式核心
private:
void putRoom(); //绘制界面
void myKLS(); // 暴力 DFS 随机生成迷宫
};
//探索模式-城堡stage
class CCastle : public CAdventure, public CUI
{
public:
CCastle() {}
~CCastle() {}
void mainGame();
private:
void putRoom(); //绘制界面
void deepFS();
};
//探索模式-营救公主stage
class CPrincess : public CAdventure, public CUI
{
public:
CPrincess() {}
~CPrincess() {}
void mainGame();
private:
void putRoom(); //绘制界面
int init(); //初始化迷宫数组
void Create(int x, int y);
};