欢迎光临
我们一直在努力

EasyX小游戏开发——跑酷游戏6:增添关卡+打包

目录

前言

增添的内容

1.关卡

2.方块种类

3.弹窗

4.转换画面

完整代码

结语


前言

这一篇文章是这个专栏的最后一篇文章,因为我以后更新文章就是在这篇文章的基础上增添的。

要打包的可以看看这篇文章。

upd(2026.4.10):更新了关卡3和弹窗,并修改了一些bug。

upd(2026.5.24):更新了关卡4和转换动画(虽然没法用),并修改了一些bug。

upd(2026.6.2):更新了关卡5-关卡8,并修改了一些bug。

增添的内容

1.关卡

现在是从 关卡1 ~ 关卡8 的进度。

int guanqia_map[101][100][180] = {
{0},//map0(没有用)
{//map1
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3},
{0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0},
{0,0,0,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
},{//map2
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3},
{0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0},
{0,0,0,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0},//4->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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
}
};

2.方块种类

到目前为止,本游戏一共出现了这几种方块:

方块图像 方块名称
泥土
草方块
钥匙
岩浆块
板子
传送门
假泥土
假草方块
假岩浆块
假传送门

(注:在最前面有“假”字的方块是可以被穿过的,小心点!)

3.弹窗

因为要我们专门看控制台的消息,所以我用了很“长”一段时间把它写了。

成品图:

bool tanchuang[1001];//有没有弹窗
int hight[1001];//从屏幕的 y=-42 开始向下移动
int tick[1001];//从第几帧开始到现在的帧数
wstring str[1001];//要输出的文字

inline void init_tanchuang(wstring s) {
int i = 0;
while (tanchuang[++i] == true);
tanchuang[i] = true;
hight[i] = -42;
tick[i] = 0;
str[i] = s;
}

void draw_tanchuang() {//画弹窗
for (int i = 1; i <= 1000; i++) {// 1000 应该没问题吧…
if (tanchuang[i] == false)continue;
int len = str[i].size();
int tanchuang_len = 0;
if (len <= 10) {
tanchuang_len = 300;
}
else {
tanchuang_len = len * 30;
}

setlinecolor(RGB(41, 151, 255));
setfillcolor(RGB(80, 170, 255));
fillroundrect(450 – (tanchuang_len / 2) – 24, hight[i], 450 + (tanchuang_len / 2) + 24, hight[i] + 42, 6, 6);

tick[i]++;

gettextstyle(&f);
f.lfHeight = 30;
settextstyle(&f);
setbkcolor(RGB(80, 170, 255));
outtextxy(450 – (len * 15), hight[i] + 6, str[i].c_str());

if (tick[i] <= 54) {// 0.6 秒弹出
hight[i]++;
}
else if (tick[i] <= 54 + 360) {//在中途停顿 4.0 秒
continue;
}
else if (tick[i] <= (54 * 2) + 360) {// 0.6秒弹回
hight[i]–;
}
else {
tanchuang[i] = false;
}
}
}

4.转换画面

写这个,主要是想到玩家在有岩浆并死亡的情况下写的,但是没法把代码套进去,让人十分的崩溃……    🙁

但是代码还是写了的。整体效果就是让屏幕闪一下(但是bug层出不穷 quq)

//这是我在网上找的
void draw_transparent_rect(int x, int y, int w, int h, COLORREF color, BYTE alpha) {
// 1. 获取主画布的 DC
HDC hdc = GetImageHDC();
if (hdc == NULL) return;

// 2. 创建兼容的内存 DC 和位图
HDC memDC = CreateCompatibleDC(hdc);
HBITMAP memBmp = CreateCompatibleBitmap(hdc, w, h);
HBITMAP oldBmp = (HBITMAP)SelectObject(memDC, memBmp);

// 3. 在内存 DC 上画纯色背景
RECT rect = { 0, 0, w, h };
HBRUSH brush = CreateSolidBrush(color);
FillRect(memDC, &rect, brush);
DeleteObject(brush); // 及时释放画刷

// 4. 配置 AlphaBlend 参数(核心!之前的错误大概率在这里)
BLENDFUNCTION bf;
bf.BlendOp = AC_SRC_OVER; // 唯一支持的混合模式
bf.BlendFlags = 0; // 必须为0
bf.SourceConstantAlpha = alpha; // 透明度(0-255)
bf.AlphaFormat = 0; // 0=忽略源位图的Alpha通道,只用上面的SourceConstantAlpha

// 5. 执行半透明贴图
AlphaBlend(
hdc, x, y, w, h, // 目标DC(主画布)和位置
memDC, 0, 0, w, h, // 源DC(内存)和位置
bf // 混合参数
);

// 6. 清理资源(非常重要,防止内存泄漏)
SelectObject(memDC, oldBmp);
DeleteObject(memBmp);
DeleteDC(memDC);
}

bool die = false;//玩家是否死亡
int die_tick;//玩家死亡后的时间
bool bianhua = false;//场景是否要变化

void draw_die() {//画死亡动效(黑屏一下)
if (die == true) {
die_tick++;
int t = 0;
if (die_tick == 32)bianhua = true;
else bianhua = false;
if (die_tick <= 32)t = die_tick * 8 – 1;
else if (die_tick <= 64)t = (64 – die_tick) * 8 + 1;
else {
die = false;
die_tick = 0;
return;
}
draw_transparent_rect(0, 0, 900, 500, RGB(0, 0, 0), t);
}
}

完整代码

#include <bits/stdc++.h>
#include <windows.h>
#include <conio.h>
#include <graphics.h>
#include<fstream>
#pragma comment(lib, "msimg32.lib")// 告诉链接器链接AlphaBlend所需的系统库
#define get_key(key) (GetAsyncKeyState(key)&0x8000)
using namespace std;

ExMessage msg;
LOGFONT f;
LINESTYLE f2;

bool running = true;

int x = 75, y = 374;//玩家x 玩家y
int x_fd = 24, y_fd = 24;//玩家x的上下幅度 玩家y的上下幅度

int sx_x = 0, sx_y = 0;//摄像机显示第x格 摄像机显示第y格
int sx_x_fd = 450, sx_y_fd = 250;//摄像机x的上下幅度 摄像机y的上下幅度

int mx = 0, my = 0;//鼠标x 鼠标y

double sd_x = 0.0, sd_y = 0.0;//速度x 速度y
bool xk = 0;//悬空
bool check_floor;//检查是否接触地块

pair<int, int> l_u[100001];//左上xy
pair<int, int> r_d[100001];//右下xy
int cnt;//个数

pair<int, int> chuansong_xy[100001];//传送门的xy(格)
pair<int, int> chuansong_l_u[100001];//传送门的左上xy
pair<int, int> chuansong_r_d[100001];//传送门的右下xy
int chuansong_cnt;//传送门个数

int g_l_u_x, g_l_u_y;
int g_r_d_x, g_r_d_y;

bool caidan = 1;//是否在菜单界面

int caidan_x = 0, caidan_y = 2;//菜单所需的摄像机xy个数(都要加一)
int caidan_chushi_x = 75, caidan_chushi_y = 374;//玩家在菜单的初始位置
int caidan_map[30][18] = {//0->空气 1->泥土 2->草地 3->回位(x=75,y=370) 4->进入游戏 5->进入设置 6->进入退出
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
2,2,2,0,0,2,2,2,0,0,2,2,2,0,0,2,2,2,
1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,//已经显示的 900*500 (每个数字代表一个 50*50 的格子)
1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,
1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,
1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,
1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,
1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,
1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,
1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,
1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,
1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,
1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,//第二层( 900*1000 )
1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,
1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,
1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,
1,1,1,0,0,1,5,0,0,0,0,3,1,0,0,1,1,1,
1,1,1,0,0,1,5,0,0,0,0,3,1,0,0,1,1,1,
1,1,1,0,0,1,1,1,1,1,1,1,1,0,0,1,1,1,
1,4,0,0,0,0,3,1,1,1,1,6,0,0,0,0,3,1,
1,4,0,0,0,0,3,1,1,1,1,6,0,0,0,0,3,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 //第三层( 900,1500 )
};

bool xuanze = 0;//是否在选择关卡界面

int ye = 1;//选择关卡的页数,每一页有10关

int guanqia_sum = 23;//总关卡数

int guanqia_kaifa = 8;//总开发关卡

int xuanze_x = 0, xuanze_y = 0;//选择关卡界面所需的摄像机xy个数(都要加一)
int xuanze_chushi_x = 75, xuanze_chushi_y = 374;//玩家在选择关卡界面的初始位置
int xuanze_map[10][18] = {//0->空气 1->泥土 2->草地 3->返回菜单 4->关卡(泥土) 5->关卡(草地) 6->板子(可以从底下跳上来,也可以跳下去) 7->上一页按钮 8->下一页按钮
7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,
0,0,5,5,6,5,5,6,5,5,6,5,5,6,5,5,0,0,
6,6,4,4,6,4,4,6,4,4,6,4,4,6,4,4,6,6,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
6,6,5,5,6,5,5,6,5,5,6,5,5,6,5,5,6,6,
0,0,4,4,6,4,4,6,4,4,6,4,4,6,4,4,0,3,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
};

bool yaoshi[101] = { false };//玩家是否拿了钥匙
pair<int, int> yaoshi_l_u[101];
pair<int, int> yaoshi_r_d[101];

int yanjiang_cnt;//岩浆的个数
pair<int, int> yanjiang_l_u[101];
pair<int, int> yanjiang_r_d[101];

int guanqia_win = 0;//赢了的关卡数
int chongzhi_tick = 0;//按下重置按钮的时间

int dimian_l_u_x[101], dimian_l_u_y[101];//地面的左上角xy(格)
int dimian_r_d_x[101], dimian_r_d_y[101];//地面的右上角xy(格)
int guanqia = 0;//在关卡界面的第几关
int guanqia_x[101] = { 0 }, guanqia_y[101] = { 0 };
int player_x[101] = { 0 }, player_y[101] = { 0 };
int guanqia_chushi_x[101], guanqia_chushi_y[101];
int guanqia_map[101][100][180] = {
{0},//map0(没有用)
{//map1
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3},
{0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,2,2,2,0,0,0,0,0},
{0,0,0,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
}
};

bool shezhi = 0;//是否在设置界面

int shezhi_x = 1, shezhi_y = 0;//设置界面所需的摄像机xy个数(都要加一)
int shezhi_chushi_x = 75, shezhi_chushi_y = 374;//玩家在设置的初始位置
int shezhi_map[10][36] = {// |分界线 0->空气 1->障碍 2->草地 3->返回菜单
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
};

bool tuichu = 0;//是否在退出界面

int tuichu_x = 0, tuichu_y = 0;//退出界面所需的摄像机xy个数(都要加一)
int tuichu_chushi_x = 75, tuichu_chushi_y = 274;//玩家在退出界面的初始位置
int tuichu_map[10][18] = {//0->空气 1->障碍 2->草地 3->返回菜单 4->退出
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
2,2,2,2,0,0,0,2,2,2,2,0,0,0,2,2,2,2,
1,1,1,1,0,0,0,0,3,1,1,0,0,0,0,4,1,1,
1,1,1,1,0,0,0,0,3,1,1,0,0,0,0,4,1,1,
1,1,1,1,2,2,2,2,2,1,1,2,2,2,2,2,1,1
};

void init_guanqia() {
guanqia_x[1] = 0;
guanqia_y[1] = 0;
player_x[1] = 0;
player_y[1] = 0;
guanqia_chushi_x[1] = 75;
guanqia_chushi_y[1] = 374;
dimian_l_u_x[1] = 0;
dimian_l_u_y[1] = 8;
dimian_r_d_x[1] = 18;
dimian_r_d_y[1] = 10;
yaoshi[1] = true;

guanqia_x[2] = 0;
guanqia_y[2] = 0;
player_x[2] = 0;
player_y[2] = 0;
guanqia_chushi_x[2] = 75;
guanqia_chushi_y[2] = 374;
dimian_l_u_x[2] = 0;
dimian_l_u_y[2] = 8;
dimian_r_d_x[2] = 18;
dimian_r_d_y[2] = 10;
yaoshi[2] = false;

guanqia_x[3] = 0;
guanqia_y[3] = 0;
player_x[2] = 0;
player_y[2] = 0;
guanqia_chushi_x[3] = 75;
guanqia_chushi_y[3] = 374;
dimian_l_u_x[3] = 0;
dimian_l_u_y[3] = 8;
dimian_r_d_x[3] = 18;
dimian_r_d_y[3] = 10;
yaoshi[3] = false;

guanqia_x[4] = 0;
guanqia_y[4] = 0;
player_x[4] = 0;
player_y[4] = 0;
guanqia_chushi_x[4] = 75;
guanqia_chushi_y[4] = 374;
dimian_l_u_x[4] = 0;
dimian_l_u_y[4] = 8;
dimian_r_d_x[4] = 18;
dimian_r_d_y[4] = 10;
yaoshi[4] = false;

guanqia_x[5] = 0;
guanqia_y[5] = 0;
player_x[5] = 0;
player_y[5] = 0;
guanqia_chushi_x[5] = 125;
guanqia_chushi_y[5] = 174;
dimian_l_u_x[5] = 0;
dimian_l_u_y[5] = 8;
dimian_r_d_x[5] = 18;
dimian_r_d_y[5] = 10;
yaoshi[5] = false;

guanqia_x[6] = 0;
guanqia_y[6] = 0;
player_x[6] = 0;
player_y[6] = 0;
guanqia_chushi_x[6] = 75;
guanqia_chushi_y[6] = 374;
dimian_l_u_x[6] = 0;
dimian_l_u_y[6] = 8;
dimian_r_d_x[6] = 18;
dimian_r_d_y[6] = 10;
yaoshi[6] = false;

guanqia_x[7] = 0;
guanqia_y[7] = 1;
player_x[7] = 0;
player_y[7] = 0;
guanqia_chushi_x[7] = 75;
guanqia_chushi_y[7] = 374;
dimian_l_u_x[7] = 0;
dimian_l_u_y[7] = 8;
dimian_r_d_x[7] = 18;
dimian_r_d_y[7] = 10;
yaoshi[7] = true;

guanqia_x[8] = 1;
guanqia_y[8] = 1;
player_x[8] = 0;
player_y[8] = 0;
guanqia_chushi_x[8] = 75;
guanqia_chushi_y[8] = 374;
dimian_l_u_x[8] = 0;
dimian_l_u_y[8] = 8;
dimian_r_d_x[8] = 18;
dimian_r_d_y[8] = 10;
yaoshi[8] = true;
}

bool tanchuang[1001];//有没有弹窗
int hight[1001];//从屏幕的 y=-42 开始向下移动
int tick[1001];//从第几帧开始到现在的帧数
wstring str[1001];//要输出的文字

inline void init_tanchuang(wstring s) {
int i = 0;
while (tanchuang[++i] == true);
tanchuang[i] = true;
hight[i] = -42;
tick[i] = 0;
str[i] = s;
}

void draw_tanchuang() {//画弹窗
for (int i = 1; i <= 1000; i++) {// 1000 应该没问题吧…
if (tanchuang[i] == false)continue;
int len = str[i].size();
int tanchuang_len = 0;
if (len <= 10) {
tanchuang_len = 300;
}
else {
tanchuang_len = len * 30;
}

setlinecolor(RGB(41, 151, 255));
setfillcolor(RGB(80, 170, 255));
fillroundrect(450 – (tanchuang_len / 2) – 24, hight[i], 450 + (tanchuang_len / 2) + 24, hight[i] + 42, 6, 6);

tick[i]++;

gettextstyle(&f);
f.lfHeight = 30;
settextstyle(&f);
setbkcolor(RGB(80, 170, 255));
outtextxy(450 – (len * 15), hight[i] + 6, str[i].c_str());

if (tick[i] <= 54) {// 0.6 秒弹出
hight[i]++;
}
else if (tick[i] <= 54 + 360) {//在中途停顿 4.0 秒
continue;
}
else if (tick[i] <= (54 * 2) + 360) {// 0.6秒弹回
hight[i]–;
}
else {
tanchuang[i] = false;
}
}
}

void read_file() {//读档
fstream ofs;
ofs.open("存档(请勿删除或修改,后果自负).txt", ios::in);
if (!ofs.is_open()) {
init_tanchuang(L"打开文件失败");
}
else {
string b;
for (int i = 1; getline(ofs, b); i++) {
if (i == 1) {
int t = 0;
for (int j = 0; j < b.size(); j++) {
t = t * 10 + (b[j] – '0');
}
guanqia_win = t;
}
}
}
ofs.close();
}

void storage_file() {//存档
fstream ofs;
ofs.open("存档(请勿删除或修改,后果自负).txt", ios::out);
ofs << guanqia_win << "\\n";
ofs.close();
}

void init() {//大部分在上面已经初始化完了(除了关卡界面,以后还要更 quq )
gettextstyle(&f);
f.lfHeight = 20;
wcscpy_s(f.lfFaceName, L"黑体");
f.lfQuality = CLEARTYPE_QUALITY;
settextstyle(&f);

getlinestyle(&f2);
f2.thickness = 2;
setlinestyle(&f2);

init_guanqia();
}

bool down = false;
bool downning = false;//按下时
void message() {
down = false;
if (peekmessage(&msg)) {
if (msg.message == WM_MOUSEMOVE) {
mx = msg.x;
my = msg.y;
}
if (msg.message == WM_LBUTTONDOWN) {
downning = true;
}
if (msg.message == WM_LBUTTONUP) {
down = true;
downning = false;
}
}
}
int s_down = false;
void message_xy() {
s_down = false;

if ((get_key('w') || get_key('W') || get_key(38)) && xk == 0) {
sd_y = 12;
}
if (get_key('a') || get_key('A') || get_key(37)) {
sd_x += 2;
}
if (get_key('d') || get_key('D') || get_key(39)) {
sd_x += -2;
}
if (get_key('s') || get_key('S') || get_key(40)) {
s_down = true;
}
sd_x *= 0.7;
if (abs(sd_x) < 0.1) {
sd_x = 0;
}
xk = 1;
}

void check() {
check_floor = 0;
int rx1 = x – x_fd, ry1 = y – y_fd;
int rx2 = x + x_fd, ry2 = y + y_fd;
for (int i = 1; i <= cnt; i++) {
int bx1 = l_u[i].first, by1 = l_u[i].second;
int bx2 = r_d[i].first, by2 = r_d[i].second;
if (rx1 <= bx2 && rx2 >= bx1 && ry1 <= by2 && ry2 >= by1) {
check_floor = 1;
return;
}
}
}

int check_chuansong() {//检查是否碰到传送门
int rx1 = x – 15, ry1 = y – 15;
int rx2 = x + 15, ry2 = y + 15;
for (int i = 1; i <= chuansong_cnt; i++) {
int bx1 = chuansong_l_u[i].first, by1 = chuansong_l_u[i].second;
int bx2 = chuansong_r_d[i].first, by2 = chuansong_r_d[i].second;
if (rx1 <= bx2 && rx2 >= bx1 && ry1 <= by2 && ry2 >= by1) {
return i;
}
}
return 0;
}

void check_yaoshi() {
int rx1 = x – x_fd, ry1 = y – y_fd;
int rx2 = x + x_fd, ry2 = y + y_fd;
int bx1 = yaoshi_l_u[guanqia].first, by1 = yaoshi_l_u[guanqia].second;
int bx2 = yaoshi_r_d[guanqia].first, by2 = yaoshi_r_d[guanqia].second;
if (rx1 <= bx2 && rx2 >= bx1 && ry1 <= by2 && ry2 >= by1) {
yaoshi[guanqia] = true;
}
}

bool check_yanjiang() {
int rx1 = x – x_fd, ry1 = y – y_fd;
int rx2 = x + x_fd, ry2 = y + y_fd;
for (int i = 1; i <= yanjiang_cnt; i++) {
int bx1 = yanjiang_l_u[i].first, by1 = yanjiang_l_u[i].second;
int bx2 = yanjiang_r_d[i].first, by2 = yanjiang_r_d[i].second;
if (rx1 <= bx2 && rx2 >= bx1 && ry1 <= by2 && ry2 >= by1) {
x = guanqia_chushi_x[guanqia];
y = guanqia_chushi_y[guanqia];
sd_x = 0;
sd_y = 0;
init_guanqia();

return true;
}
}
return false;
}

void x_push(double sd_x_t) {
x -= sd_x_t;
if (check_yanjiang() == true) {
sx_x = player_x[guanqia];
sx_y = player_y[guanqia];
return;
}
check();
if (check_floor > 0) {
sd_x = 0;
for (int i = 1; i <= ceil(abs(sd_x_t)); i++) {
if (check_floor > 0) {
x += sd_x_t / abs(sd_x_t);
if (check_yanjiang() == true){
sx_x = player_x[guanqia];
sx_y = player_y[guanqia];
return;
}
check();
}
else {
return;
}
}
}
}

void y_push(double sd_y_t) {
y -= sd_y_t;
if (check_yanjiang() == true) {
sx_x = player_x[guanqia];
sx_y = player_y[guanqia];
return;
}
check();
if (check_floor > 0) {
sd_y = 0;
if (sd_y_t < 0) {
xk = 0;
}
for (int i = 1; i <= ceil(abs(sd_y_t)); i++) {
if (check_floor > 0) {
y += sd_y_t / abs(sd_y_t);
if (check_yanjiang() == true) {
sx_x = player_x[guanqia];
sx_y = player_y[guanqia];
return;
}
check();
}
else {
return;
}
}
}
}

//这是我在网上找的
void draw_transparent_rect(int x, int y, int w, int h, COLORREF color, BYTE alpha) {
// 1. 获取主画布的 DC
HDC hdc = GetImageHDC();
if (hdc == NULL) return;

// 2. 创建兼容的内存 DC 和位图
HDC memDC = CreateCompatibleDC(hdc);
HBITMAP memBmp = CreateCompatibleBitmap(hdc, w, h);
HBITMAP oldBmp = (HBITMAP)SelectObject(memDC, memBmp);

// 3. 在内存 DC 上画纯色背景
RECT rect = { 0, 0, w, h };
HBRUSH brush = CreateSolidBrush(color);
FillRect(memDC, &rect, brush);
DeleteObject(brush); // 及时释放画刷

// 4. 配置 AlphaBlend 参数(核心!之前的错误大概率在这里)
BLENDFUNCTION bf;
bf.BlendOp = AC_SRC_OVER; // 唯一支持的混合模式
bf.BlendFlags = 0; // 必须为0
bf.SourceConstantAlpha = alpha; // 透明度(0-255)
bf.AlphaFormat = 0; // 0=忽略源位图的Alpha通道,只用上面的SourceConstantAlpha

// 5. 执行半透明贴图
AlphaBlend(
hdc, x, y, w, h, // 目标DC(主画布)和位置
memDC, 0, 0, w, h, // 源DC(内存)和位置
bf // 混合参数
);

// 6. 清理资源(非常重要,防止内存泄漏)
SelectObject(memDC, oldBmp);
DeleteObject(memBmp);
DeleteDC(memDC);
}

bool die = false;//玩家是否死亡
int die_tick;//玩家死亡后的时间
bool bianhua = false;//场景是否要变化

void draw_die() {//画死亡动效(黑屏一下)
if (die == true) {
die_tick++;
int t = 0;
if (die_tick == 32)bianhua = true;
else bianhua = false;
if (die_tick <= 32)t = die_tick * 8 – 1;
else if (die_tick <= 64)t = (64 – die_tick) * 8 + 1;
else {
die = false;
die_tick = 0;
return;
}
draw_transparent_rect(0, 0, 900, 500, RGB(0, 0, 0), t);
}
}

void shezhi_bianjie() {//设置边界(顺便把障碍也画了)

g_l_u_x = sx_x * 18;
g_l_u_y = sx_y * 10;//左上格坐标
g_r_d_x = sx_x * 18 + 17;
g_r_d_y = sx_y * 10 + 9;//右下格坐标

for (int i = g_l_u_y; i <= g_r_d_y; i++) {
for (int j = g_l_u_x; j <= g_r_d_x; j++) {
int tx = (j – g_l_u_x) * 50, ty = (i – g_l_u_y) * 50;
if (caidan == true && caidan_map[i][j] != 0) {
cnt++;
l_u[cnt] = { tx,ty };
r_d[cnt] = { tx + 50 ,ty + 50 };
setfillcolor(RGB(110, 60, 29));
solidrectangle(tx, ty, tx + 50, ty + 50);
if (caidan_map[i][j] % 10 == 2) {
setfillcolor(RGB(70, 208, 1));
solidrectangle(tx, ty, tx + 50, ty + 20);
}
else if (caidan_map[i][j] % 10 >= 3 && caidan_map[i][j] % 10 <= 6) {
setfillcolor(RGB(85, 170, 255));
solidrectangle(tx, ty, tx + 50, ty + 50);

cnt–;

chuansong_cnt++;

chuansong_xy[chuansong_cnt] = { i,j };

chuansong_l_u[chuansong_cnt] = { tx,ty };
chuansong_r_d[chuansong_cnt] = { tx + 50,ty + 50 };
}
}
else if (xuanze == true && xuanze_map[i][j] != 0) {
cnt++;
l_u[cnt] = { tx,ty };
r_d[cnt] = { tx + 50 ,ty + 50 };
setfillcolor(RGB(110, 60, 29));
solidrectangle(tx, ty, tx + 50, ty + 50);
if (xuanze_map[i][j] % 10 == 2 || xuanze_map[i][j] % 10 == 5) {
setfillcolor(RGB(70, 208, 1));
solidrectangle(tx, ty, tx + 50, ty + 20);
}
else if (xuanze_map[i][j] % 10 == 3) {
setfillcolor(RGB(85, 170, 255));
solidrectangle(tx, ty, tx + 50, ty + 50);

cnt–;

chuansong_cnt++;

chuansong_xy[chuansong_cnt] = { i,j };

chuansong_l_u[chuansong_cnt] = { tx,ty };
chuansong_r_d[chuansong_cnt] = { tx + 50,ty + 50 };
}
else if (xuanze_map[i][j] % 10 == 6) {
setfillcolor(RGB(69, 169, 255));
solidrectangle(tx, ty, tx + 50, ty + 50);

setfillcolor(RGB(255, 187, 0));
solidrectangle(tx, ty, tx + 50, ty + 2);

int t_x = x + x_fd, t_y = y + y_fd;
if (t_y > ty || s_down == true) {//如果玩家的底部y值 > 这一个格子的顶部y值(就是比这一格低)
cnt–;
}
}
else if (xuanze_map[i][j] % 10 >= 7 && xuanze_map[i][j] % 10 <= 8) {
setfillcolor(RGB(0, 191, 255));
solidrectangle(tx, ty, tx + 50, ty + 50);
}
}
else if (guanqia != 0 && guanqia_map[guanqia][i][j] != 0) {
cnt++;
l_u[cnt] = { tx,ty };
r_d[cnt] = { tx + 50 ,ty + 50 };
setfillcolor(RGB(110, 60, 29));
solidrectangle(tx, ty, tx + 50, ty + 50);
if (guanqia_map[guanqia][i][j] % 10 == 1) {
if (guanqia_map[guanqia][i][j] / 10 == 1) {
cnt–;
}
}
if (guanqia_map[guanqia][i][j] % 10 == 2) {
setfillcolor(RGB(70, 208, 1));
solidrectangle(tx, ty, tx + 50, ty + 20);
if (guanqia_map[guanqia][i][j] / 10 == 1) {
cnt–;
}
}
else if (guanqia_map[guanqia][i][j] % 10 == 3) {
setfillcolor(RGB(85, 170, 255));
solidrectangle(tx, ty, tx + 50, ty + 50);

cnt–;

if (yaoshi[guanqia] == true && guanqia_map[guanqia][i][j] / 10 == 0) {
chuansong_cnt++;

chuansong_xy[chuansong_cnt] = { i,j };

chuansong_l_u[chuansong_cnt] = { tx,ty };
chuansong_r_d[chuansong_cnt] = { tx + 50,ty + 50 };
}
}
else if (guanqia_map[guanqia][i][j] % 10 == 4) {//开门的钥匙
cnt–;

if (i >= dimian_l_u_y[guanqia] && i <= dimian_r_d_y[guanqia] && j >= dimian_l_u_x[guanqia] && j <= dimian_r_d_x[guanqia]) {
setfillcolor(RGB(139, 98, 73));
}
else {
setfillcolor(RGB(69, 169, 255));
}
solidrectangle(tx, ty, tx + 50, ty + 50);

if (yaoshi[guanqia] == false) {
setfillcolor(RGB(255, 244, 125));
fillcircle(tx + 25, ty + 25, 24);

yaoshi_l_u[guanqia] = { tx,ty };
yaoshi_r_d[guanqia] = { tx + 50,ty + 50 };

check_yaoshi();
}
}
else if (guanqia_map[guanqia][i][j] % 10 == 5) {//板子
setfillcolor(RGB(69, 169, 255));
solidrectangle(tx, ty, tx + 50, ty + 50);

setfillcolor(RGB(255, 187, 0));
solidrectangle(tx, ty, tx + 50, ty + 2);

int t_x = x + x_fd, t_y = y + y_fd;
if (t_y > ty || s_down == true) {//如果玩家的底部y值 > 这一个格子的顶部y值(就是比这一格低)
cnt–;
}
}
else if (guanqia_map[guanqia][i][j] % 10 == 6) {//岩浆块
setfillcolor(RGB(255, 160, 0));
solidrectangle(tx, ty, tx + 50, ty + 50);

yanjiang_cnt++;
yanjiang_l_u[yanjiang_cnt] = { tx,ty };
yanjiang_r_d[yanjiang_cnt] = { tx + 50,ty + 50 };
}
else if (guanqia_map[guanqia][i][j] % 10 == 7) {//假岩浆块
setfillcolor(RGB(255, 160, 0));
solidrectangle(tx, ty, tx + 50, ty + 50);
}
}
else if (shezhi == true && shezhi_map[i][j] != 0) {
cnt++;
l_u[cnt] = { tx,ty };
r_d[cnt] = { tx + 50 ,ty + 50 };
setfillcolor(RGB(110, 60, 29));
solidrectangle(tx, ty, tx + 50, ty + 50);
if (shezhi_map[i][j] % 10 == 2) {
setfillcolor(RGB(70, 208, 1));
solidrectangle(tx, ty, tx + 50, ty + 20);
}
else if (shezhi_map[i][j] % 10 == 3) {
setfillcolor(RGB(85, 170, 255));
solidrectangle(tx, ty, tx + 50, ty + 50);

cnt–;

chuansong_cnt++;

chuansong_xy[chuansong_cnt] = { i,j };

chuansong_l_u[chuansong_cnt] = { tx,ty };
chuansong_r_d[chuansong_cnt] = { tx + 50,ty + 50 };
}
}
else if (tuichu == true && tuichu_map[i][j] != 0) {
cnt++;
l_u[cnt] = { tx,ty };
r_d[cnt] = { tx + 50 ,ty + 50 };
setfillcolor(RGB(110, 60, 29));
solidrectangle(tx, ty, tx + 50, ty + 50);
if (tuichu_map[i][j] % 10 == 2) {
setfillcolor(RGB(70, 208, 1));
solidrectangle(tx, ty, tx + 50, ty + 20);
}
if (tuichu_map[i][j] % 10 >= 3 && tuichu_map[i][j] % 10 <= 4) {
setfillcolor(RGB(85, 170, 255));
solidrectangle(tx, ty, tx + 50, ty + 50);

cnt–;

chuansong_cnt++;

chuansong_xy[chuansong_cnt] = { i,j };

chuansong_l_u[chuansong_cnt] = { tx,ty };
chuansong_r_d[chuansong_cnt] = { tx + 50,ty + 50 };
}
}
}
}
}

pair<int, int> chuansong_line_xy[1000001];//放在函数里面会爆栈 quq 别问我是怎么知道的
int ans_chuansong = 0;

pair<int, int> yanjiang_line_xy[1000001];
int ans_yanjiang = 0;

void draw_line() {
setlinecolor(BLACK);

for (int i = g_l_u_y; i <= g_r_d_y; i++) {
for (int j = g_l_u_x; j <= g_r_d_x; j++) {
int tx = (j – g_l_u_x) * 50, ty = (i – g_l_u_y) * 50;
if (caidan == true && caidan_map[i][j] != 0) {
if (caidan_map[i][j] % 10 == 1 || caidan_map[i][j] % 10 == 2) {
line(tx, ty, tx + 50, ty);
line(tx, ty, tx, ty + 50);
line(tx + 50, ty, tx + 50, ty + 50);
line(tx, ty + 50, tx + 50, ty + 50);
}
else if (caidan_map[i][j] % 10 >= 3 && caidan_map[i][j] % 10 <= 6) {//上半部分传送门
if (caidan_map[i + 1][j] % 10 >= 3 && caidan_map[i + 1][j] % 10 <= 6) {//下半部分传送门
ans_chuansong++;
chuansong_line_xy[ans_chuansong].first = tx;
chuansong_line_xy[ans_chuansong].second = ty;
}
}
}
else if (xuanze == true && xuanze_map[i][j] != 0) {
if (xuanze_map[i][j] % 10 == 1 || xuanze_map[i][j] % 10 == 2 || xuanze_map[i][j] % 10 == 7 || xuanze_map[i][j] == 8) {
line(tx, ty, tx + 50, ty);
line(tx, ty, tx, ty + 50);
line(tx + 50, ty, tx + 50, ty + 50);
line(tx, ty + 50, tx + 50, ty + 50);
}
else if (xuanze_map[i][j] % 10 == 3) {//上半部分传送门
if (xuanze_map[i + 1][j] % 10 == 3) {//下半部分传送门
ans_chuansong++;
chuansong_line_xy[ans_chuansong].first = tx;
chuansong_line_xy[ans_chuansong].second = ty;
}
}
else if (xuanze_map[i][j] % 10 == 5) {
if (xuanze_map[i + 1][j] % 10 == 4 && xuanze_map[i][j + 1] % 10 == 5) {
line(tx, ty, tx + 100, ty);
line(tx, ty, tx, ty + 100);
line(tx + 100, ty, tx + 100, ty + 100);
line(tx, ty + 100, tx + 100, ty + 100);
}
}
}
else if (guanqia != 0 && guanqia_map[guanqia][i][j] != 0) {
if (guanqia_map[guanqia][i][j] % 10 == 1 || guanqia_map[guanqia][i][j] % 10 == 2) {
line(tx, ty, tx + 50, ty);
line(tx, ty, tx, ty + 50);
line(tx + 50, ty, tx + 50, ty + 50);
line(tx, ty + 50, tx + 50, ty + 50);
}
else if (guanqia_map[guanqia][i][j] % 10 == 3) {//上半部分传送门
if (guanqia_map[guanqia][i + 1][j] % 10 == 3) {//下半部分传送门
ans_chuansong++;
chuansong_line_xy[ans_chuansong].first = tx;
chuansong_line_xy[ans_chuansong].second = ty;

if (yaoshi[guanqia] == false) {
setlinecolor(RED);
line(tx, ty, tx + 50, ty + 100);
line(tx + 50, ty, tx, ty + 100);
setlinecolor(BLACK);
}
}
}
else if (guanqia_map[guanqia][i][j] % 10 == 6 || guanqia_map[guanqia][i][j] % 10 == 7) {//岩浆块
ans_yanjiang++;
yanjiang_line_xy[ans_yanjiang].first = tx;
yanjiang_line_xy[ans_yanjiang].second = ty;
}
}
else if (shezhi == true && shezhi_map[i][j] % 10 != 0) {
if (shezhi_map[i][j] % 10 == 1 || shezhi_map[i][j] % 10 == 2) {
line(tx, ty, tx + 50, ty);
line(tx, ty, tx, ty + 50);
line(tx + 50, ty, tx + 50, ty + 50);
line(tx, ty + 50, tx + 50, ty + 50);
}
else if (shezhi_map[i][j] % 10 == 3) {//上半部分传送门
if (shezhi_map[i + 1][j] >= 3 && shezhi_map[i + 1][j] <= 6) {//下半部分传送门
ans_chuansong++;
chuansong_line_xy[ans_chuansong].first = tx;
chuansong_line_xy[ans_chuansong].second = ty;
}
}

}
else if (tuichu == true && tuichu_map[i][j] != 0) {
if (tuichu_map[i][j] % 10 == 1 || tuichu_map[i][j] % 10 == 2) {
line(tx, ty, tx + 50, ty);
line(tx, ty, tx, ty + 50);
line(tx + 50, ty, tx + 50, ty + 50);
line(tx, ty + 50, tx + 50, ty + 50);
}
else if (tuichu_map[i][j] % 10 >= 3 && tuichu_map[i][j] % 10 <= 4) {//上半部分传送门
if (tuichu_map[i + 1][j] % 10 >= 3 && tuichu_map[i + 1][j] % 10 <= 6) {//下半部分传送门
ans_chuansong++;
chuansong_line_xy[ans_chuansong].first = tx;
chuansong_line_xy[ans_chuansong].second = ty;
}
}
}
}
}
for (int i = 1; i <= ans_yanjiang; i++) {
int tx = yanjiang_line_xy[i].first, ty = yanjiang_line_xy[i].second;
setlinecolor(RGB(255, 60, 0));
line(tx, ty, tx + 50, ty);
line(tx + 50, ty, tx + 50, ty + 50);
line(tx + 50, ty + 50, tx, ty + 50);
line(tx, ty + 50, tx, ty);
}
for (int i = 1; i <= ans_chuansong; i++) {
int tx = chuansong_line_xy[i].first, ty = chuansong_line_xy[i].second;
setlinecolor(RGB(255, 215, 0));
line(tx, ty, tx + 50, ty);
line(tx + 50, ty, tx + 50, ty + 100);
line(tx + 50, ty + 100, tx, ty + 100);
line(tx, ty + 100, tx, ty);
}
ans_yanjiang = 0;
ans_chuansong = 0;
}

void draw_player() {//画玩家
setfillcolor(RGB(128, 128, 128));
solidrectangle(x – x_fd, y – y_fd, x + x_fd, y + y_fd);

setlinecolor(BLACK);
line(x – x_fd, y – y_fd, x – x_fd, y + y_fd);
line(x – x_fd, y – y_fd, x + x_fd, y – y_fd);
line(x + x_fd, y + y_fd, x + x_fd, y – y_fd);
line(x + x_fd, y + y_fd, x – x_fd, y + y_fd);
}

void draw_text() {
if (caidan == true) {
int guanqia_text_x = 165, guanqia_text_y = 400;//关卡文字x 关卡文字y

int shezhi_text_x = 415, shezhi_text_y = 400;//设置文字x 设置文字y

int tuichu_text_x = 665, tuichu_text_y = 400;//退出文字x 退出文字y

if (sx_x == 0 && sx_y == 0) {
gettextstyle(&f);
f.lfHeight = 100;
settextstyle(&f);

setbkcolor(RGB(69, 169, 255));

settextcolor(BLACK);
outtextxy(100, 50, L"跑酷");

outtextxy(100, 150, L"游戏");

gettextstyle(&f);
f.lfHeight = 35;
settextstyle(&f);

setbkcolor(RGB(139, 98, 73));

outtextxy(guanqia_text_x, guanqia_text_y, L"关卡");

outtextxy(shezhi_text_x, shezhi_text_y, L"设置");

outtextxy(tuichu_text_x, tuichu_text_y, L"退出");
}
else {
gettextstyle(&f);
f.lfHeight = 35;
settextstyle(&f);

setbkcolor(RGB(139, 98, 73));

outtextxy(guanqia_text_x, 0, L"关卡");

outtextxy(shezhi_text_x, 0, L"设置");

outtextxy(tuichu_text_x, 0, L"退出");
}
if (sx_x == 0 && sx_y == 2) {//传送门
gettextstyle(&f);
f.lfHeight = 20;
settextstyle(&f);

setbkcolor(RGB(85, 170, 255));

outtextxy(305, 190, L"设置");

outtextxy(555, 180, L"返回");
outtextxy(555, 200, L"菜单");

outtextxy(55, 330, L"开始");
outtextxy(55, 350, L"游戏");

outtextxy(305, 330, L"返回");
outtextxy(305, 350, L"菜单");

outtextxy(555, 340, L"退出");

outtextxy(805, 330, L"返回");
outtextxy(805, 350, L"菜单");
}
}
else if (xuanze == true) {
if (sx_x == 0 && sx_y == 0) {
gettextstyle(&f);
f.lfHeight = 20;
settextstyle(&f);

setbkcolor(RGB(85, 170, 255));

outtextxy(855, 330, L"返回");
outtextxy(855, 350, L"菜单");

gettextstyle(&f);
f.lfHeight = 14;
settextstyle(&f);

setbkcolor(RGB(0, 191, 255));

outtextxy(3, 17, L"上一页");
outtextxy(853, 17, L"下一页");

gettextstyle(&f);
f.lfHeight = 30;
settextstyle(&f);

setbkcolor(RGB(69, 169, 255));

outtextxy(212, 210, L"按下 ↓(或S) 键可以从 下去");

settextcolor(RGB(255, 187, 0));

outtextxy(527, 210, L"板子上");

settextcolor(BLACK);

message();

if (mx <= 50 && my <= 50 && down == true) {
if (ye > 1) {
ye–;
}
}

if (mx >= 850 && my <= 50 && down == true) {
if (ye < guanqia_sum – (guanqia_sum / 10) == 0 ? guanqia_sum / 10 : guanqia_sum / 10 + 1) {
ye++;
}
}

int left = (ye – 1) * 10, right = 0;
if (ye * 10 > guanqia_sum) {//如果这一页所能展示的最大关卡数 > 总关卡数
right = guanqia_sum;
}
else {
right = ye * 10;
}

int mod = right – left;
wchar_t t[100];
int tx = 0, ty = 0;//输出的坐标

gettextstyle(&f);
f.lfHeight = 30;
settextstyle(&f);

setbkcolor(RGB(110, 60, 29));
settextcolor(WHITE);

setlinecolor(RED);
int win = guanqia_win + 1;

if (mod >= 1) {//输出关卡编号——————–分界线(因为有亿点长)—————————–
ty = 85;
if (left + 1 < 10) {
tx = 135;
}
else if (left + 1 < 100) {
tx = 120;
}
else if (left + 1 < 1000) {//估计达不到100关
tx = 105;
}
_itow_s(left + 1, t, 10);//int 转 wchar_t ,不然会报错
outtextxy(tx, ty, t);

if (win < left + 1) {
line(100, 50, 200, 150);
line(200, 50, 100, 150);
}
}
if (mod >= 2) {
ty = 85;
if (left + 2 < 10) {
tx = 285;
}
else if (left + 2 < 100) {
tx = 270;
}
else if (left + 2 < 1000) {
tx = 255;
}
_itow_s(left + 2, t, 10);
outtextxy(tx, ty, t);

if (win < left + 2) {
line(250, 50, 350, 150);
line(350, 50, 250, 150);
}
}
if (mod >= 3) {
ty = 85;
if (left + 3 < 10) {
tx = 435;
}
else if (left + 3 < 100) {
tx = 420;
}
else if (left + 3 < 1000) {
tx = 405;
}
_itow_s(left + 3, t, 10);
outtextxy(tx, ty, t);

if (win < left + 3) {
line(400, 50, 500, 150);
line(500, 50, 400, 150);
}
}
if (mod >= 4) {
ty = 85;
if (left + 4 < 10) {
tx = 585;
}
else if (left + 4 < 100) {
tx = 570;
}
else if (left + 4 < 1000) {
tx = 555;
}
_itow_s(left + 4, t, 10);
outtextxy(tx, ty, t);

if (win < left + 4) {
line(550, 50, 650, 150);
line(650, 50, 550, 150);
}
}
if (mod >= 5) {
ty = 85;
if (left + 5 < 10) {
tx = 735;
}
else if (left + 5 < 100) {
tx = 720;
}
else if (left + 5 < 1000) {
tx = 705;
}
_itow_s(left + 5, t, 10);
outtextxy(tx, ty, t);

if (win < left + 5) {
line(700, 50, 800, 150);
line(800, 50, 700, 150);
}
}
if (mod >= 6) {
ty = 285;
if (left + 6 < 10) {
tx = 135;
}
else if (left + 6 < 100) {
tx = 120;
}
else if (left + 6 < 1000) {
tx = 105;
}
_itow_s(left + 6, t, 10);
outtextxy(tx, ty, t);

if (win < left + 6) {
line(100, 250, 200, 350);
line(200, 250, 100, 350);
}
}
if (mod >= 7) {
ty = 285;
if (left + 7 < 10) {
tx = 285;
}
else if (left + 7 < 100) {
tx = 270;
}
else if (left + 7 < 1000) {
tx = 255;
}
_itow_s(left + 7, t, 10);
outtextxy(tx, ty, t);

if (win < left + 7) {
line(250, 250, 350, 350);
line(350, 250, 250, 350);
}
}
if (mod >= 8) {
ty = 285;
if (left + 8 < 10) {
tx = 435;
}
else if (left + 8 < 100) {
tx = 420;
}
else if (left + 8 < 1000) {
tx = 405;
}
_itow_s(left + 8, t, 10);
outtextxy(tx, ty, t);

if (win < left + 8) {
line(400, 250, 500, 350);
line(500, 250, 400, 350);
}
}
if (mod >= 9) {
ty = 285;
if (left + 9 < 10) {
tx = 585;
}
else if (left + 9 < 100) {
tx = 570;
}
else if (left + 9 < 1000) {
tx = 555;
}
_itow_s(left + 9, t, 10);
outtextxy(tx, ty, t);

if (win < left + 9) {
line(550, 250, 650, 350);
line(650, 250, 550, 350);
}
}
if (mod >= 10) {
ty = 285;
if (left + 10 < 100) {
tx = 730;
}
else if (left + 10 < 1000) {
tx = 715;
}
_itow_s(left + 10, t, 10);
outtextxy(tx, ty, t);

if (win < left + 10) {
line(700, 250, 800, 350);
line(800, 250, 700, 350);
}
}//———————————————-分界线———————————————
settextcolor(BLACK);

if (down == true) {
bool flag = false;
if (mx >= 100 && mx <= 200 && my >= 50 && my <= 150) {
if (left + 1 > guanqia_kaifa) {
init_tanchuang(L"还未开发,敬请期待");
}
else if (win < left + 1) {
init_tanchuang(L"您还未解锁此关卡,请先完成前面的关卡");
}
else {
x = guanqia_chushi_x[left + 1];
y = guanqia_chushi_y[left + 1];
xuanze = false;
guanqia = left + 1;
flag = true;
}
}
if (mx >= 250 && mx <= 350 && my >= 50 && my <= 150) {
if (left + 2 > guanqia_kaifa) {
init_tanchuang(L"还未开发,敬请期待");
}
else if (win < left + 2) {
init_tanchuang(L"您还未解锁此关卡,请先完成前面的关卡");
}
else {
x = guanqia_chushi_x[left + 2];
y = guanqia_chushi_y[left + 2];
xuanze = false;
guanqia = left + 2;
flag = true;
}
}
if (mx >= 400 && mx <= 500 && my >= 50 && my <= 150) {
if (left + 3 > guanqia_kaifa) {
init_tanchuang(L"还未开发,敬请期待");
}
else if (win < left + 3) {
init_tanchuang(L"您还未解锁此关卡,请先完成前面的关卡");
}
else {
x = guanqia_chushi_x[left + 3];
y = guanqia_chushi_y[left + 3];
xuanze = false;
guanqia = left + 3;
flag = true;
}
}
if (mx >= 550 && mx <= 650 && my >= 50 && my <= 150) {
if (left + 4 > guanqia_kaifa) {
init_tanchuang(L"还未开发,敬请期待");
}
else if (win < left + 4) {
init_tanchuang(L"您还未解锁此关卡,请先完成前面的关卡");
}
else {
x = guanqia_chushi_x[left + 4];
y = guanqia_chushi_y[left + 4];
xuanze = false;
guanqia = left + 4;
flag = true;
}
}
if (mx >= 700 && mx <= 800 && my >= 50 && my <= 150) {
if (left + 5 > guanqia_kaifa) {
init_tanchuang(L"还未开发,敬请期待");
}
else if (win < left + 5) {
init_tanchuang(L"您还未解锁此关卡,请先完成前面的关卡");
}
else {
x = guanqia_chushi_x[left + 5];
y = guanqia_chushi_y[left + 5];
xuanze = false;
guanqia = left + 5;
flag = true;
}
}
if (mx >= 100 && mx <= 200 && my >= 250 && my <= 350) {
if (left + 6 > guanqia_kaifa) {
init_tanchuang(L"还未开发,敬请期待");
}
else if (win < left + 6) {
init_tanchuang(L"您还未解锁此关卡,请先完成前面的关卡");
}
else {
x = guanqia_chushi_x[left + 6];
y = guanqia_chushi_y[left + 6];
xuanze = false;
guanqia = left + 6;
flag = true;
}
}
if (mx >= 250 && mx <= 350 && my >= 250 && my <= 350) {
if (left + 7 > guanqia_kaifa) {
init_tanchuang(L"还未开发,敬请期待");
}
else if (win < left + 7) {
init_tanchuang(L"您还未解锁此关卡,请先完成前面的关卡");
}
else {
x = guanqia_chushi_x[left + 7];
y = guanqia_chushi_y[left + 7];
xuanze = false;
guanqia = left + 7;
flag = true;
}
}
if (mx >= 400 && mx <= 500 && my >= 250 && my <= 350) {
if (left + 8 > guanqia_kaifa) {
init_tanchuang(L"还未开发,敬请期待");
}
else if (win < left + 8) {
init_tanchuang(L"您还未解锁此关卡,请先完成前面的关卡");
}
else {
x = guanqia_chushi_x[left + 8];
y = guanqia_chushi_y[left + 8];
xuanze = false;
guanqia = left + 8;
flag = true;
}
}
if (mx >= 550 && mx <= 650 && my >= 250 && my <= 350) {
if (left + 9 > guanqia_kaifa) {
init_tanchuang(L"还未开发,敬请期待");
}
else if (win < left + 9) {
init_tanchuang(L"您还未解锁此关卡,请先完成前面的关卡");
}
else {
x = guanqia_chushi_x[left + 9];
y = guanqia_chushi_y[left + 9];
xuanze = false;
guanqia = left + 9;
flag = true;
}
}
if (mx >= 700 && mx <= 800 && my >= 250 && my <= 350) {
if (left + 10 > guanqia_kaifa) {
init_tanchuang(L"还未开发,敬请期待");
}
else if (win < left + 10) {
init_tanchuang(L"您还未解锁此关卡,请先完成前面的关卡");
}
else {
x = guanqia_chushi_x[left + 10];
y = guanqia_chushi_y[left + 10];
xuanze = false;
guanqia = left + 10;
flag = true;
}
}
if (flag == true) {
sd_x = 0;
sd_y = 0;

sx_x = 0;
sx_y = 0;
}
}
}
}
else if (guanqia != 0) {
if (guanqia == 1) {
gettextstyle(&f);
f.lfHeight = 25;
settextstyle(&f);

setbkcolor(RGB(69, 169, 255));

settextcolor(BLACK);

outtextxy(575, 17, L"这是传送门,进去就过关↓");
}
else if (guanqia == 2) {
gettextstyle(&f);
f.lfHeight = 25;
settextstyle(&f);

setbkcolor(RGB(69, 169, 255));

settextcolor(BLACK);

outtextxy(625, 17, L"这个传送门好像不对劲");

outtextxy(575, 317, L"这是钥匙,可以开门↓");
}
else if (guanqia == 4) {
gettextstyle(&f);
f.lfHeight = 25;
settextstyle(&f);

setbkcolor(RGB(69, 169, 255));

settextcolor(BLACK);

outtextxy(275, 367, L"↓这个东西看起来很危险欸");
}
else if (guanqia == 6) {
gettextstyle(&f);
f.lfHeight = 25;
settextstyle(&f);

setbkcolor(RGB(69, 169, 255));

settextcolor(BLACK);

outtextxy(275, 367, L"和第四关一样?");
}
}
else if (shezhi == true) {
if (sx_x == 0 && sx_y == 0) {
gettextstyle(&f);//传送门
f.lfHeight = 20;
settextstyle(&f);

setbkcolor(RGB(85, 170, 255));

outtextxy(855, 330, L"返回");
outtextxy(855, 350, L"菜单");

gettextstyle(&f);
f.lfHeight = 30;
settextstyle(&f);

setbkcolor(RGB(255, 173, 0));

outtextxy(330, 20, L"长按清空存档记录");

setlinecolor(BLACK);

line(330, 20, 570, 20);
line(330, 50, 570, 50);
line(330, 20, 330, 50);
line(570, 20, 570, 50);

message();

if (mx >= 330 && mx <= 570 && my >= 20 && my <= 50 && downning == true) {
chongzhi_tick++;
if (chongzhi_tick >= 5 * 90) {
chongzhi_tick = 0;
guanqia_win = 0;
storage_file();
init_tanchuang(L"重置成功");
}
}
}
}
else if (tuichu == true) {
int caidan_text_x = 240, caidan_text_y = 300;//菜单文字x 菜单文字y

int tuichu_text_x = 590, tuichu_text_y = 300;//退出文字x 退出文字y

gettextstyle(&f);
f.lfHeight = 35;
settextstyle(&f);

setbkcolor(RGB(139, 98, 73));

outtextxy(caidan_text_x, caidan_text_y, L"菜单");

outtextxy(tuichu_text_x, tuichu_text_y, L"退出");

gettextstyle(&f);//传送门
f.lfHeight = 20;
settextstyle(&f);

setbkcolor(RGB(85, 170, 255));

outtextxy(405, 380, L"返回");
outtextxy(405, 400, L"菜单");

outtextxy(755, 390, L"退出");
}
}

int main() {
initgraph(900, 500);

SetWindowText(GetHWnd(), L"跑酷游戏");

read_file();

init();

BeginBatchDraw();

const double PHYSICS_STEP = 1.0 / 90.0;
double accumulator = 0.0;
LARGE_INTEGER freq, prev_time, curr_time;
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&prev_time);

while (running) {

cleardevice();

QueryPerformanceCounter(&curr_time);
double delta_time = (curr_time.QuadPart – prev_time.QuadPart) / (double)freq.QuadPart;
prev_time = curr_time;

setfillcolor(RGB(69, 169, 255));
solidrectangle(0, 0, 900, 500);

if (caidan == true) {
if (sx_x == 0 && sx_y == 0) {
setfillcolor(RGB(139, 98, 73));
solidrectangle(0, 400, 900, 500);
}
else {
setfillcolor(RGB(139, 98, 73));
solidrectangle(0, 0, 900, 500);
}
}
else if (xuanze == true) {
init_guanqia();

setfillcolor(RGB(139, 98, 73));
solidrectangle(0, 400, 900, 500);
}
else if (guanqia != 0) {
if (guanqia == 5) {
setfillcolor(RGB(139, 98, 73));
solidrectangle(0, 250, 900, 500);
}
}
else if (shezhi == true) {
if (sx_x == 0 && sx_y == 0) {
setfillcolor(RGB(139, 98, 73));
solidrectangle(0, 400, 900, 500);
}
else if (sx_x == 1 && sx_y == 0) {
setfillcolor(RGB(139, 98, 73));
solidrectangle(0, 300, 900, 500);
}
}
else if (tuichu == true) {
setfillcolor(RGB(139, 98, 73));
solidrectangle(0, 300, 900, 500);
}

int jiemian_x = 0, jiemian_y = 0;
if (caidan == true) {
jiemian_x = caidan_x;
jiemian_y = caidan_y;
}
else if (xuanze == true) {
jiemian_x = xuanze_x;
jiemian_y = xuanze_y;
}
else if (guanqia != 0) {
jiemian_x = guanqia_x[guanqia];
jiemian_y = guanqia_y[guanqia];
}
else if (shezhi == true) {
jiemian_x = shezhi_x;
jiemian_y = shezhi_y;
}
else if (tuichu == true) {
jiemian_x = tuichu_x;
jiemian_y = tuichu_y;
}

if (sx_y == jiemian_y) {//y轴
l_u[++cnt] = { 0,500 };
r_d[cnt] = { 900,500 };
}

if (sx_y < jiemian_y) {
if (y < 0) {
sx_y–;
y = 500;
}
}

if (sx_y == 0) {
l_u[++cnt] = { 0,0 };
r_d[cnt] = { 900,0 };
}

if (sx_y >= 0) {
if (y > 500) {
sx_y++;
y = 0;
}
}

if (sx_x == jiemian_x) {//x轴
l_u[++cnt] = { 900,0 };
r_d[cnt] = { 900,500 };
}

if (sx_x < jiemian_x) {
if (x > 900) {
sx_x++;
x = 0;
}
}

if (sx_x == 0) {
l_u[++cnt] = { 0,0 };
r_d[cnt] = { 0,500 };
}

if (sx_x > 0) {
if (x < 0) {
sx_x–;
x = 900;
}
}

shezhi_bianjie();

getlinestyle(&f2);
f2.thickness = 2;
setlinestyle(&f2);

draw_line();

draw_text();

int sum = check_chuansong();

if (sum != 0) {
//die = true;
pair<int, int> t_l_u = chuansong_xy[sum];
int tx = t_l_u.first, ty = t_l_u.second;
if (caidan == true) {
if (caidan_map[tx][ty] == 3) {
x = caidan_chushi_x;
y = caidan_chushi_y;
}
else if (caidan_map[tx][ty] == 4) {//进入游戏
x = xuanze_chushi_x;
y = xuanze_chushi_y;
caidan = false;
xuanze = true;
ye = 1;
}
else if (caidan_map[tx][ty] == 5) {//进入设置
x = shezhi_chushi_x;
y = shezhi_chushi_y;
caidan = false;
shezhi = true;
}
else if (caidan_map[tx][ty] == 6) {//退出
x = tuichu_chushi_x;
y = tuichu_chushi_y;
caidan = false;
tuichu = true;
}
}
else if (xuanze == true) {
if (xuanze_map[tx][ty] == 3) {
x = caidan_chushi_x;
y = caidan_chushi_y;
xuanze = false;
caidan = true;
}
}
else if (guanqia != 0) {
if (guanqia_map[guanqia][tx][ty] == 3) {
x = xuanze_chushi_x;
y = xuanze_chushi_y;
guanqia_win = max(guanqia, guanqia_win);
guanqia = 0;
storage_file();
xuanze = true;
}
}
else if (shezhi == true) {
if (shezhi_map[tx][ty] == 3) {
x = caidan_chushi_x;
y = caidan_chushi_y;
shezhi = false;
caidan = true;
}
}
else if (tuichu == true) {
if (tuichu_map[tx][ty] == 3) {
x = caidan_chushi_x;
y = caidan_chushi_y;
tuichu = false;
caidan = true;
}
else if (tuichu_map[tx][ty] == 4) {//退出
running = false;
}
}
else {
die = false;
}
sd_x = 0;
sd_y = 0;

sx_x = 0;
sx_y = 0;
}

if (die == false) {
accumulator += delta_time;
while (accumulator >= PHYSICS_STEP) {
sd_y -= 0.5 * PHYSICS_STEP * 75; // 重力按物理步长缩放
message_xy();
x_push(sd_x * PHYSICS_STEP * 75 * 1.0);
y_push(sd_y * PHYSICS_STEP * 75 * 1.0);
accumulator -= PHYSICS_STEP;
}
}

draw_player();

draw_tanchuang();

draw_die();

chuansong_cnt = 0;

cnt = 0;

yanjiang_cnt = 0;

FlushBatchDraw();
if (delta_time < PHYSICS_STEP) {
Sleep((PHYSICS_STEP – delta_time) * 1000);
}
}
EndBatchDraw();
closegraph();

storage_file();
return 0;
}

结语

评论呢????????????????????????????????????????

赞(0)
未经允许不得转载:171主机测评 » EasyX小游戏开发——跑酷游戏6:增添关卡+打包
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址