迷宫闯关 V1.4.2 !
- 第一次打小游戏,做的不好请见谅!~
V1.3.x
- 加入了商店,并对游玩体验进行了优化
V1.3.0 (2023/8/6)
- 加入了“技能”和“商店”功能
- 将炸弹和地雷爆炸设定为连锁反应
- 进一步优化代码长度
V1.3.1
- 修复了炸弹被多次引爆的问题
- 修复了地图左下角总是出现空位,导致爆炸输出越界的问题
- 修复了不经常自动存档的问题
- 修复了在收集血包时可以无限加血的问题
- 修复了炸弹爆炸时加血和加分会再次调用的问题
- 修复了已开启但未通过第五关时商店就解锁的问题
V1.3.2
- 加入了存档问题检测,使随意更改存档成为过去
- 加入了技能面板
- 进一步优化代码长度
V1.3.3.1 (2023/8/8)
- 加入了消耗品商店,可购买血包和技能体验卡
- 加入了当铺,可以用来倒卖消耗品
- 优化了技能面板
- 进一步优化了代码长度,并修改了大量已知 B U G BUG BUG,优化了游玩体验
小修改
- 提高了技能的价格
- H a r d Hard Hard 模式下通过第 3 3 3 关就可以解锁商店
V1.3.4
- 在中等和困难模式中加入 5 × 5 5 \times 5 5×5 的大炸弹
- 大炸弹的爆炸范围内的碎砖墙可能发生破碎
- 将炸弹伤害与距离爆炸中心的距离挂钩
小修改
- 降低了爆炸产生碎砖墙的概率
V1.4
- 加入了探索模式。
V1.4.0 (2023/8/26)
- 加入了探索模式,将原先的正常迷宫归入扫荡模式(通关后才能进入扫荡模式)。
- 修复了已知 B U G BUG BUG。
V1.4.1.3
- 加入了“地毯”。
- 将未失明时的地图探索做出了一点小更改。
- 优化了代码长度并修复了已知 B U G BUG BUG。
V1.4.2 (2023/9/22)
- 加入键位修改功能。
- 更改每一关的胜利界面的小细节(没法直接进入商店了)。
- 将部分按键改为平滑检测。
- 修复了已知 B U G BUG BUG。
代码啥的
话不多说,直接上 游戏代码!
代码
#include <bits/stdc++.h>
#include <windows.h>
#define maxn 20
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1 : 0)
using namespace std;
int mp[200][200] = {
0}, rx, ry, score = 0, blood = 10, bao = 0, sgless;
int nandu, op[10] = {
0}, boomm[100] = {
0}, len = 1, rlen = 1, facing;
int costsco[maxn] = {
0, 40, 30, 50, 40, 25, 20, 15, 10, 20, 15};
int needblo[maxn] = {
0, 1, 4, 0, -1, -2, 1, 4, 0, -1};
int dir[5][2] = {
{
0, 0}, {
0, -1}, {
-1, 0}, {
0, 1}, {
1, 0}}, have[maxn];
char whichkey[] = {
'Q', 'Z', 'X', 37, 38, 39, 40, 'A', 'W', 'D', 'S'};
bool issg, isopen, isup[260];
float xt = 0;
string thisgamename;
char keyname[260][60] = {
"", "鼠标左键", "鼠标右键", "[Ctrl]+[Break]",
"鼠标中键", "X1 鼠标按钮", "X2 鼠标按钮", "", "[Backspace]", "[Tab]", "", "",
"[Clear]", "[Enter]", "", "", "[Shift]", "[Ctrl]", "[Alt]", "[Pause]",
"[CapsLock]", "", "", "", "", "", "", "[Esc]", "", "", "", "", "[Space]",
"[PageUp]", "[PageDown]", "[End]", "[Home]", "[Left]", "[Up]", "[Right]",
"[Down]", "[Select]", "[Print]", "[Execute]", "[PrintScreen]", "[Insert]",
"[Delete]", "[Help]", "[0]", "[1]", "[2]", "[3]", "[4]", "[5]", "[6]", "[7]",
"[8]", "[9]", "", "", "", "", "", "", "", "[A]", "[B]", "[C]", "[D]", "[E]",
"[F]", "[G]", "[H]", "[I]", "[J]", "[K]", "[L]", "[M]", "[N]", "[O]", "[p]",
"[Q]", "[R]", "[S]", "[T]", "[U]", "[V]", "[W]", "[X]", "[Y]", "[Z]", "左[Win]",
"右[Win]", "[App]", "", "[Sleep]", "小键盘[0]", "小键盘[1]", "小键盘[2]",
"小键盘[3]", "小键盘[4]", "小键盘[5]", "小键盘[6]", "小键盘[7]", "小键盘[8]",
"小键盘[9]", "[×]", "[+]", "[分隔符]", "[-]", "[Dec]", "[/]", "[F1]", "[F2]",
"[F3]", "[F4]", "[F5]", "[F6]", "[F7]", "[F8]", "[F9]", "[F10]", "[F11]",
"[F12]", "[F13]", "[F14]", "[F15]", "[F16]", "[F17]", "[F18]", "[F19]", "[F20]",
"[F21]", "[F22]", "[F23]", "[F24]", "", "", "", "", "", "", "", "", "[NumLock]",
"[ScrollLock]", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"左[Shift]", "右[Shift]", "左[Ctrl]", "右[Ctrl]", "左[Alt]", "右[Alt]", "", "", "", "",
"", "", "", "静音", "音量减小", "音量增加", "下一首", "上一首", "停止", "播放/暂停",
"启动邮件", "选择媒体", "启动应用程序_1", "启动应用程序_2", "", "", "[;]",
"[+]", "[,]", "[-]", "[.]", "[/]", "[~]", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "[{]", "[\\]",
"[}]", "[']", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "[Attn]", "[CrSel]", "[ExSel]", "[ErEOF]", "播放键",
"缩放键", "", "[PA1]", "清除键"
};
struct blk {
char ch[3];
int clr;
blk (const char *s = " ", int a = 7) {
ch[0] = s[0], ch[1] = s[1], ch[2] = '\0', clr = a;
}
} blocks[11];
struct node {
int x, y;
};
queue<node> boom;
inline void color(int a) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), a);
}
inline void gto(int x, int y) {
COORD pos;
pos.X = y;
pos.Y = x;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
bool new_game(), cundang(), read(string name), game(), to_start();
bool checkup(int x, int y, int n), whichmod(int n), notwall(int x, int y);
bool isair(int x, int y);
int gq(int n, bool mod), rnk(int x, bool y = 1);
void start(), jiaocheng(), shop(), jinengshop(), scoshop(), huishou();
void whichxitong(), dlt(string name), all_clear(), sout(string a, int t);
void update(int x), manout(int n), mpout(int n, bool mod), goofput(int rx, int ry);
void lose(int num), win(), addvis(int n), boardout(int n), prt(int x, int y);
void booom(int n, bool mod), boomclear(), mpout(int x, int y, bool isbig, bool mod);
void save(string name), look(int n, bool mod), go_though(int x, int y, int n);
void addop(int x, int y, int n, int face), setkey(), change(int x);
void whichxitong() {
typedef void(__stdcall * NTPROC)(DWORD *, DWORD *, DWORD *);
HINSTANCE hinst = LoadLibrary("ntdll.dll");
DWORD dwMajor, dwMinor, dwBuildNumber;
NTPROC proc = (NTPROC)GetProcAddress(hinst, "RtlGetNtVersionNumbers");
proc(&dwMajor, &dwMinor, &dwBuildNumber);
if (dwMajor == 10 && dwMinor == 0) {
xt = 10;
return ;
}
SYSTEM_INFO info;
GetSystemInfo(&info);
OSVERSIONINFOEX os;
os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if (GetVersionEx((OSVERSIONINFO *)&os)) {
if (os.dwMajorVersion == 6 && os.wProductType == VER_NT_WORKSTATION) {
xt = 7;
}
}
}
int main() {
srand((unsigned)time(NULL));
blocks[6] = blocks[0] = {
" ", 238};
blocks[4] = blocks[3] = blocks[1] = {
" ", 119};
blocks[2] = {
"!!", 27};
blocks[10] = blocks[5] = {
"[]", 236};
blocks[7] = {
"☆", 231};
blocks[8] = {
"☆", 236};
blocks[9] = {
"国", 120};
for (int i = 1; i <= 256; i++) {
if (!KEY_DOWN(i)) {
isup[i] = 1;
}
}
start();
return 0;
}
bool read(string name) {
string str = name + ".save";
char ch[30];
memset(ch, 0, sizeof ch);
for (unsigned int i = 0; i < str.size(); i++) {
ch[i] = str[i];
}
char *s = ch;
FILE *fp = fopen(s, "r");
fscanf(fp, "%d%d%d%d", &nandu, &blood, &bao, &score);
bool isold = 0;
unsigned long long hsh = rnk(nandu, 0) + rnk(blood, 0) + rnk(bao, 0) + rnk(score, 0), thehsh;
for (int i = 0; i < 10; i++) {
fscanf(fp, "%d", op + i);
hsh += rnk(op[i], 0);
}
for (int i = 1; i < maxn; i++) {
if (fscanf(fp, "%d", have + i) == EOF) isold = 1, have[i] = 0;
hsh += rnk(have[i], 0);
}
have[5] = bao;
int a = 0;
if (fscanf(fp, "%d", &a) == EOF) {
isold = 1, isopen = 0;
} else {
isopen = ((a || (nandu == 3 ? op[4] : op[6])) ? 1 : 0);
}
hsh += rnk(isopen, 0);
for (int i = 0; i <= 10; i++) {
if (fscanf(fp, "%d", &a) == EOF) isold = 1;
else whichkey[i] = a;
hsh += rnk(whichkey[i], 0);
}
if (fscanf(fp, "%llu", &thehsh) == EOF) isold = 1;
fclose(fp);
if (thehsh != hsh && !isold) return 0;
if (isopen == 0) memset(have, 0, sizeof have);
save(name);
return 1;
}
void save(string name) {
name += ".save";
char ch[30];
memset(ch, 0, sizeof ch);
for (unsigned int i = 0; i < name.size(); i++) ch[i] = name[i];
char *s = ch;
FILE *fp = fopen(s, "w");
fprintf(fp, "%d %d %d %d ", nandu, blood, bao, score);
unsigned long long hsh = rnk(nandu, 0) + rnk(blood, 0) + rnk(bao, 0) + rnk(score, 0);
for (int i = 0; i < 10; i++) {
fprintf(fp, "%d ", op[i]);
hsh += rnk(op[i], 0);
}
for (int i = 1; i < maxn; i++) {
have[5] = bao;
fprintf(fp, "%d ", have[i]);
hsh += rnk(have[i], 0);
}
isopen |= (nandu == 3 ? op[4] : op[6]);
fprintf(fp, "%d ", isopen), hsh += rnk(isopen, 0);
for (int i = 0; i <= 10; i++) {
fprintf(fp, "%d ", whichkey[i]);
hsh += rnk(whichkey[i], 0);
}
fprintf(fp, "%llu", hsh);
fclose(fp);
return ;
}
string keys[] = {
"", "使用血包", "感知", "跃迁", "向左", "向上", "向右", "向下"};
void change(int x) {
bool flag = 0;
color(7), gto(x * 2 + 6, 4), cout << keys[x], color(13);
gto(x * 2 + 6, 15), printf("[ %s ] ", keyname[(int)whichkey[x - 1]]);
Sleep(50);
while (1) {
for (int i = 2; i <= 256; i++)
if (