写的一个推箱子小游戏本来打算用c写但后还偷懒用了一点stl(只用了队列来处理 广度优先搜索 来对判断鼠标指令进行处理)
用了easyx绘图工具
代码的话
然后的话总共弄了8关
图片和音频可以自己弄 我是用的小黄人的那一套
大概逻辑就如代码这样 呃呃就这样吧
总之 说有的情况都可以转化为 这几类
1 先把b1移动到c1处,再把a1移动到b1处
2不能移动
3吧a3移动到b3处
基本的移动逻辑可以化为这几种 然后简单实现一下即可
在说一下在写的过程中遇到了一些问题
1需要对ps有一定了解,处理成所需要的图片
2需要对c中媒体资源有一定了解
3最重要的是我刚开始写出来的在其他电脑运行不了,技术太菜后来就直接把动态库换成静态 编译然后就好了很多 至少宿舍里边的电脑都能直接用了
大概就这些 图片音频不知道能不能放 所以我就不在这写了
总之还有好多好多缺陷 不过终于没有了明显bug 然后就 不想继续往下写了没什么意思
#include
#include
#include
#include
#include
#pragma comment(lib, "Winmm.lib");
#define Max 10
using namespace std;
struct node1 {
int position_x, position_y;
};
struct node {
int map[16][16];
int position_x, position_y;
node1 box[20];
int vis[16][16];
int vis1[16][16];
int cnt;
}check[Max], tmp;
IMAGE img_wall, img_picture, img_back, music_1, music_2, music_0;
int sum;
int esc;
int music;
int muse_move_flag;
void updatewithinput();
void show1();
void show();
void init();
void init1();
void init2();
void init3();
void init4();
void init5();
void init6();
void init7();
void init8();
void menu1();
void menu2();
void turn_on_music();
void turn_off_music();
int judge_point(int x1, int y1, int x2, int y2);
int muse_move(int xx, int yy);
void gameover();
void pass();
int main() {
init();
initgraph(960, 832);
HWND hwnd = GetHWnd();
SetWindowText(hwnd, "推箱子 v1.0");
int i;
turn_on_music();
int num = 1;
while (1) {
menu1();
MOUSEMSG m;
if (MouseHit())
{
m = GetMouseMsg();
if (m.uMsg == WM_LBUTTONUP)
{
if (m.x <= 350 && m.x >= 200 && m.y <= 240 && m.y >= 200)
{
break;
}
else if (m.x <= 350 && m.x >= 200 && m.y <= 340 && m.y >= 300) {
cleardevice();
outtextxy(200, 200, "请输入关卡:(总8关)");
char x;
x = _getch();
num = x - '0';
break;
}
else if (m.x <= 260 && m.x >= 200 && m.y <= 440 && m.y >= 400) {
return 0;
}
else if (m.x >= 800 && m.x <= 860 && m.y >= 20 && m.y <= 80) {
if (music == 1) {
turn_off_music();
}
else if (music == 0) {
turn_on_music();
}
}
}
}
}
for (i = num; i <= 8; i++) {
cleardevice();
HWND hwnd = GetHWnd();
switch (i) {
case 1:init1(); SetWindowText(hwnd, "推箱子 v1.0 第1关"); break;
case 2:init2(); SetWindowText(hwnd, "推箱子 v1.0 第2关"); break;
case 3:init3(); SetWindowText(hwnd, "推箱子 v1.0 第3关"); break;
case 4:init4(); SetWindowText(hwnd, "推箱子 v1.0 第4关"); break;
case 5:init5(); SetWindowText(hwnd, "推箱子 v1.0 第5关"); break;
case 6:init6(); SetWindowText(hwnd, "推箱子 v1.0 第6关"); break;
case 7:init7(); SetWindowText(hwnd, "推箱子 v1.0 第7关"); break;
case 8:init8(); SetWindowText(hwnd, "推箱子 v1.0 第8关"); break;
}
tmp = check[i];
show();
show1();
if (music == 1) {
putimage(800, 20, &music_0, NOTSRCERASE);
putimage(800, 20, &music_1, SRCINVERT);
}
if (music == 0) {
putimage(800, 20, &music_0, NOTSRCERASE);
putimage(800, 20, &music_2, SRCINVERT);
}
sum = 0;
int flag = 0;
while (1) {
updatewithinput();
if (esc == 1) {
menu2();
MOUSEMSG m;
if (MouseHit())
{
m = GetMouseMsg();
if (m.uMsg == WM_LBUTTONUP)
{
if (m.x <= 350 && m.x >= 200 && m.y <= 340 && m.y >= 300)
{
esc = 0;
break;
}
else if (m.x <= 260 && m.x >= 200 && m.y <= 440 && m.y >= 400) {
return 0;
}
}
}
}
int j;
MOUSEMSG m;
if (MouseHit())
{
m = GetMouseMsg();
if (m.uMsg == WM_LBUTTONUP)
{
if (m.x >= 800 && m.x <= 860 && m.y >= 20 && m.y <= 80) {
if (music == 1) {
turn_off_music();
}
else if (music == 0) {
turn_on_music();
}
}
muse_move_flag = 0;
muse_move_flag = muse_move(m.x, m.y);
}
}
for (j = 1; j <= tmp.cnt; j++) {
int x = tmp.box[j].position_x;
int y = tmp.box[j].position_y;
if (tmp.map[y][x] != 4) {
break;
}
}
if (j == tmp.cnt + 1) {
flag = 1;
pass();
while (1) {
if (MouseHit())
{
m = GetMouseMsg();
if (m.uMsg == WM_LBUTTONUP)
{
if (m.x <= 320 && m.x >= 200 && m.y <= 240 && m.y >= 200)
{
break;
}
else if (m.x <= 350 && m.x >= 200 && m.y <= 340 && m.y >= 300) {
i--;
break;
}
else if (m.x <= 260 && m.x >= 200 && m.y <= 440 && m.y >= 400) {
return 0;
}
else if (m.x >= 800 && m.x <= 860 && m.y >= 20 && m.y <= 80) {
if (music == 1) {
turn_off_music();
}
else if (music == 0) {
turn_on_music();
}
}
}
}
}
break;
}
}
if (flag == 1)continue;
else {
i--;
continue;
}
}
gameover();
return 0;
}
void menu1() {
settextcolor(RED);
settextstyle(40, 0, _T("宋体"));
outtextxy(200, 200, "开始游戏");
outtextxy(200, 300, "选择关卡");
outtextxy(200, 400, "退出");
}
void menu2() {
settextcolor(RED);
settextstyle(40, 0, _T("宋体"));
outtextxy(200, 300, "重新开始");
outtextxy(200, 400, "退出");
}
void gameover() {
cleardevice();
settextcolor(RED);
settextstyle(40, 0, _T("宋体"));
outtextxy(200, 200, "游戏结束");
while (1) {
MOUSEMSG m;
if (MouseHit())
{
m = GetMouseMsg();
if (m.uMsg == WM_LBUTTONUP)
{
if (m.x <= 350 && m.x >= 200 && m.y <= 240 && m.y >= 200)
{
break;
}
}
}
}
}
void pass() {
settextcolor(RED);
settextstyle(40, 0, _T("宋体"));
outtextxy(200, 200, "下一关");
outtextxy(200, 300, "重玩本关");
outtextxy(200, 400, "退出");
}
int judge_point(int x1, int y1, int x2, int y2) {
queue q;
node1 point_1;
point_1.position_x = x1;
point_1.position_y = y1;
int vis_point[20][20];
memset(vis_point, 0, sizeof(vis_point));
q.push(point_1);
vis_point[y1][x1] = 1;
int bp[4][2] = { 1, 0, -1, 0, 0, 1, 0, -1 };
while (!q.empty()) {
node1 point_2;
point_2 = q.front();
q.pop();
if (point_2.position_x == x2 && point_2.position_y == y2) {
return 1;
}
for (int i = 0; i <= 3; i++) {
point_1.position_x = bp[i][0] + point_2.position_x;
point_1.position_y = bp[i][1] + point_2.position_y;
if (point_1.position_x == x2 && point_1.position_y == y2) {
return 1;
}
if (!vis_point[point_1.position_y][point_1.position_x] && (tmp.map[point_1.position_y][point_1.position_x] == 2 || tmp.map[point_1.position_y][point_1.position_x] == 4) && !tmp.vis1[point_1.position_y][point_1.position_x]) {
q.push(point_1);
vis_point[point_1.position_y][point_1.position_x] = 1;
}
}
}
return 0;
}
void show() {
int i, j;
for (i = 1; i <= 13; i++) {
for (j = 1; j <= 15; j++) {
int x = (j - 1) * 64;
int y = (i - 1) * 64;
if (tmp.map[i][j] == 0) {
putimage(x, y, 64, 64, &img_back, 128, 64, NOTSRCERASE);
putimage(x, y, 64, 64, &img_picture, 128, 64, SRCINVERT);
}
if (tmp.map[i][j] == 1) {
//putimage(x, y, &img_wall, NOTSRCERASE);
putimage(x, y, &img_wall, SRCINVERT);
}
if (tmp.map[i][j] == 2 || tmp.map[i][j] == 3 || tmp.map[i][j] == 4) {
putimage(x, y, 64, 64, &img_back, 128, 0, NOTSRCERASE);
putimage(x, y, 64, 64, &img_picture, 128, 0, SRCINVERT);
}
if (tmp.map[i][j] == 4) {
putimage(x + 16, y + 16, 32, 32, &img_back, 0, 384, NOTSRCERASE);
putimage(x + 16, y + 16, 32, 32, &img_picture, 0, 384, SRCINVERT);
}
if (tmp.map[i][j] == 3) {
putimage(x, y, 64, 64, &img_back, 192, 0, NOTSRCERASE);
putimage(x, y, 64, 64, &img_picture, 192, 0, SRCINVERT);
}
if (tmp.position_x == j && tmp.position_y == i) {
putimage(x + 13, y + 7, 38, 57, &img_back, 320, 365, NOTSRCERASE);
putimage(x + 13, y + 7, 38, 57, &img_picture, 320, 365, SRCINVERT);
}
}
}
}
void show1() {
int i;
for (i = 1; i <= tmp.cnt; i++) {
int x = tmp.box[i].position_x;
int y = tmp.box[i].position_y;
putimage((x - 1) * 64, (y - 1) * 64, 64, 64, &img_back, 192, 0, NOTSRCERASE);
putimage((x - 1) * 64, (y - 1) * 64, 64, 64, &img_picture, 192, 0, SRCINVERT);
}
}
void turn_on_music() {
mciSendString("open .\\backmusic.mp3 alias bkmusic", NULL, 0, NULL);
mciSendString("play bkmusic repeat", NULL, 0, NULL);
music = 1;
putimage(800, 20, &music_0, NOTSRCERASE);
putimage(800, 20, &music_1, SRCINVERT);
}
void turn_off_music() {
music = 0;
mciSendString("close bkmusic", NULL, 0, NULL);
putimage(800, 20, &music_0, NOTSRCERASE);
putimage(800, 20, &music_2, SRCINVERT);
}
int muse_move(int xx, int yy) {
int x, y;
if (xx % 64) {
x = xx / 64 + 1;
}
else {
x = xx / 64;
}
if (yy % 64) {
y = yy / 64 + 1;
}
else {
y = yy / 64;
}
if ((tmp.map[y][x] == 2 || tmp.map[y][x] == 4) && !tmp.vis1[y][x] && !(y == tmp.position_y && x == tmp.position_x)) {
if (judge_point(tmp.position_x, tmp.position_y, x, y)) {
putimage((tmp.position_x - 1) * 64, (tmp.position_y - 1) * 64, 64, 64, &img_back, 128, 0, NOTSRCERASE);
putimage((tmp.position_x - 1) * 64, (tmp.position_y - 1) * 64, 64, 64, &img_picture, 128, 0, SRCINVERT);
if (tmp.map[tmp.position_y][tmp.position_x] == 4) {
putimage((tmp.position_x - 1) * 64 + 16, (tmp.position_y - 1) * 64 + 16, 32, 32, &img_back, 0, 384, NOTSRCERASE);
putimage((tmp.position_x - 1) * 64 + 16, (tmp.position_y - 1) * 64 + 16, 32, 32, &img_picture, 0, 384, SRCINVERT);
tmp.vis[tmp.position_y][tmp.position_x] = 0;
}
if (tmp.map[y][x] == 4) {
tmp.vis[y][x] = 1;
}
putimage((x - 1) * 64 + 13, (y - 1) * 64 + 7, 38, 57, &img_back, 320, 365, NOTSRCERASE);
putimage((x - 1) * 64 + 13, (y - 1) * 64 + 7, 38, 57, &img_picture, 320, 365, SRCINVERT);
tmp.position_x = x;
tmp.position_y = y;
}
}
int p_x = tmp.position_x;
int p_y = tmp.position_y;
if (tmp.vis1[y][x]) {
if (p_x == x) {
if (p_y - 1 == y) {
return 1;
}
else if (p_y + 1 == y) {
return 2;
}
}
if (p_y == y) {
if (p_x - 1 == x) {
return 3;
}
else if (p_x + 1 == x) {
return 4;
}
}
}
return 0;
}
void updatewithinput() {
char input;
while (_kbhit() || muse_move_flag) {
input = 'l';
if(!muse_move_flag)input = _getch();
int x = tmp.position_x;
int y = tmp.position_y;
if (input == 'w' || muse_move_flag == 1) {
int i;
for (i = 1; i <= tmp.cnt; i++) {
if (tmp.box[i].position_x == x && tmp.box[i].position_y == y - 1) {
if ((tmp.map[y - 2][x] == 2 && tmp.vis1[y - 2][x] == 0) || (tmp.map[y - 2][x] == 4 && tmp.vis[y - 2][x] == 0)) {
int xx = tmp.box[i].position_x;
int yy = tmp.box[i].position_y;
putimage((xx - 1) * 64, (yy - 1) * 64, 64, 64, &img_back, 128, 0, NOTSRCERASE);
putimage((xx - 1) * 64, (yy - 1) * 64, 64, 64, &img_picture, 128, 0, SRCINVERT);
tmp.vis1[yy][xx] = 0;
if (tmp.map[yy][xx] == 4) {
putimage((x - 1) * 64 + 16, (y - 1) * 64 + 16, 32, 32, &img_back, 0, 384, NOTSRCERASE);
putimage((x - 1) * 64 + 16, (y - 1) * 64 + 16, 32, 32, &img_picture, 0, 384, SRCINVERT);
tmp.vis[yy][xx] = 0;
}
tmp.box[i].position_y--;
yy--;
tmp.vis1[yy][xx] = 1;
if (tmp.map[yy][xx] == 4) {
tmp.vis[yy][xx] = 1;
}
putimage((xx - 1) * 64, (yy - 1) * 64, 64, 64, &img_back, 192, 0, NOTSRCERASE);
putimage((xx - 1) * 64, (yy - 1) * 64, 64, 64, &img_picture, 192, 0, SRCINVERT);
}
}
}
if ((tmp.map[y - 1][x] == 2 && tmp.vis1[y - 1][x] == 0) || (tmp.map[y - 1][x] == 4 && tmp.vis[y - 1][x] == 0)) {
putimage((x - 1) * 64, (y - 1) * 64, 64, 64, &img_back, 128, 0, NOTSRCERASE);
putimage((x - 1) * 64, (y - 1) * 64, 64, 64, &img_picture, 128, 0, SRCINVERT);
if (tmp.map[y][x] == 4) {
putimage((x - 1) * 64 + 16, (y - 1) * 64 + 16, 32, 32, &img_back, 0, 384, NOTSRCERASE);
putimage((x - 1) * 64 + 16, (y - 1) * 64 + 16, 32, 32, &img_picture, 0, 384, SRCINVERT);
tmp.vis[y][x] = 0;
}
tmp.position_y--;
y--;
if (tmp.map[y][x] == 4) {
tmp.vis[y][x] = 1;
}
putimage((x - 1) * 64 + 13, (y - 1) * 64 + 7, 38, 57, &img_back, 320, 365, NOTSRCERASE);
putimage((x - 1) * 64 + 13, (y - 1) * 64 + 7, 38, 57, &img_picture, 320, 365, SRCINVERT);
}
}
if (input == 's' || muse_move_flag == 2) {
int i;
for (i = 1; i <= tmp.cnt; i++) {
if (tmp.box[i].position_x == x && tmp.box[i].position_y == y + 1) {
if ((tmp.map[y + 2][x] == 2 && tmp.vis1[y + 2][x] == 0) || (tmp.map[y + 2][x] == 4 && tmp.vis[y + 2][x] == 0)) {
int xx = tmp.box[i].position_x;
int yy = tmp.box[i].position_y;
tmp.vis1[yy][xx] = 0;
putimage((xx - 1) * 64, (yy - 1) * 64, 64, 64, &img_back, 128, 0, NOTSRCERASE);
putimage((xx - 1) * 64, (yy - 1) * 64, 64, 64, &img_picture, 128, 0, SRCINVERT);
if (tmp.map[yy][xx] == 4) {
putimage((x - 1) * 64 + 16, (y - 1) * 64 + 16, 32, 32, &img_back, 0, 384, NOTSRCERASE);
putimage((x - 1) * 64 + 16, (y - 1) * 64 + 16, 32, 32, &img_picture, 0, 384, SRCINVERT);
tmp.vis[yy][xx] = 0;
}
tmp.box[i].position_y++;
yy++;
tmp.vis1[yy][xx] = 1;
if (tmp.map[yy][xx] == 4) {
tmp.vis[yy][xx] = 1;
}
putimage((xx - 1) * 64, (yy - 1) * 64, 64, 64, &img_back, 192, 0, NOTSRCERASE);
putimage((xx - 1) * 64, (yy - 1) * 64, 64, 64, &img_picture, 192, 0, SRCINVERT);
}
}
}
if ((tmp.map[y + 1][x] == 2 && tmp.vis1[y + 1][x] == 0) || (tmp.map[y + 1][x] == 4 && tmp.vis[y + 1][x] == 0)) {
putimage((x - 1) * 64, (y - 1) * 64, 64, 64, &img_back, 128, 0, NOTSRCERASE);
putimage((x - 1) * 64, (y - 1) * 64, 64, 64, &img_picture, 128, 0, SRCINVERT);
if (tmp.map[y][x] == 4) {
putimage((x - 1) * 64 + 16, (y - 1) * 64 + 16, 32, 32, &img_back, 0, 384, NOTSRCERASE);
putimage((x - 1) * 64 + 16, (y - 1) * 64 + 16, 32, 32, &img_picture, 0, 384, SRCINVERT);
tmp.vis[y][x] = 0;
}
tmp.position_y++;
y++;
if (tmp.map[y][x] == 4) {
tmp.vis[y][x] = 1;
}
putimage((x - 1) * 64 + 13, (y - 1) * 64 + 7, 38, 57, &img_back, 320, 365, NOTSRCERASE);
putimage((x - 1) * 64 + 13, (y - 1) * 64 + 7, 38, 57, &img_picture, 320, 365, SRCINVERT);
}
}
if (input == 'a' || muse_move_flag == 3) {
int i;
for (i = 1; i <= tmp.cnt; i++) {
if (tmp.box[i].position_x == x - 1 && tmp.box[i].position_y == y) {
if ((tmp.map[y][x - 2] == 2 && tmp.vis1[y][x - 2] == 0) || (tmp.map[y][x - 2] == 4 && tmp.vis[y][x - 2] == 0)) {
int xx = tmp.box[i].position_x;
int yy = tmp.box[i].position_y;
tmp.vis1[yy][xx] = 0;
putimage((xx - 1) * 64, (yy - 1) * 64, 64, 64, &img_back, 128, 0, NOTSRCERASE);
putimage((xx - 1) * 64, (yy - 1) * 64, 64, 64, &img_picture, 128, 0, SRCINVERT);
if (tmp.map[yy][xx] == 4) {
putimage((x - 1) * 64 + 16, (y - 1) * 64 + 16, 32, 32, &img_back, 0, 384, NOTSRCERASE);
putimage((x - 1) * 64 + 16, (y - 1) * 64 + 16, 32, 32, &img_picture, 0, 384, SRCINVERT);
tmp.vis[yy][xx] = 0;
}
tmp.box[i].position_x--;
xx--;
tmp.vis1[yy][xx] = 1;
if (tmp.map[yy][xx] == 4) {
tmp.vis[yy][xx] = 1;
}
putimage((xx - 1) * 64, (yy - 1) * 64, 64, 64, &img_back, 192, 0, NOTSRCERASE);
putimage((xx - 1) * 64, (yy - 1) * 64, 64, 64, &img_picture, 192, 0, SRCINVERT);
}
}
}
if ((tmp.map[y][x - 1] == 2 && tmp.vis1[y][x - 1] == 0) || (tmp.map[y][x - 1] == 4 && tmp.vis[y][x - 1] == 0)) {
putimage((x - 1) * 64, (y - 1) * 64, 64, 64, &img_back, 128, 0, NOTSRCERASE);
putimage((x - 1) * 64, (y - 1) * 64, 64, 64, &img_picture, 128, 0, SRCINVERT);
if (tmp.map[y][x] == 4) {
putimage((x - 1) * 64 + 16, (y - 1) * 64 + 16, 32, 32, &img_back, 0, 384, NOTSRCERASE);
putimage((x - 1) * 64 + 16, (y - 1) * 64 + 16, 32, 32, &img_picture, 0, 384, SRCINVERT);
tmp.vis[y][x] = 0;
}
tmp.position_x--;
x--;
if (tmp.map[y][x] == 4) {
tmp.vis[y][x] = 1;
}
putimage((x - 1) * 64 + 13, (y - 1) * 64 + 7, 38, 57, &img_back, 320, 365, NOTSRCERASE);
putimage((x - 1) * 64 + 13, (y - 1) * 64 + 7, 38, 57, &img_picture, 320, 365, SRCINVERT);
}
}
if (input == 'd' || muse_move_flag == 4) {
int i;
for (i = 1; i <= tmp.cnt; i++) {
if (tmp.box[i].position_x == x + 1 && tmp.box[i].position_y == y) {
if ((tmp.map[y][x + 2] == 2 && tmp.vis1[y][x + 2] == 0) || (tmp.map[y][x + 2] == 4 && tmp.vis[y][x + 2] == 0)) {
int xx = tmp.box[i].position_x;
int yy = tmp.box[i].position_y;
tmp.vis1[yy][xx] = 0;
putimage((xx - 1) * 64, (yy - 1) * 64, 64, 64, &img_back, 128, 0, NOTSRCERASE);
putimage((xx - 1) * 64, (yy - 1) * 64, 64, 64, &img_picture, 128, 0, SRCINVERT);
if (tmp.map[yy][xx] == 4) {
putimage((x - 1) * 64 + 16, (y - 1) * 64 + 16, 32, 32, &img_back, 0, 384, NOTSRCERASE);
putimage((x - 1) * 64 + 16, (y - 1) * 64 + 16, 32, 32, &img_picture, 0, 384, SRCINVERT);
tmp.vis[yy][xx] = 0;
}
tmp.box[i].position_x++;
xx++;
tmp.vis1[yy][xx] = 1;
if (tmp.map[yy][xx] == 4) {
tmp.vis[yy][xx] = 1;
}
putimage((xx - 1) * 64, (yy - 1) * 64, 64, 64, &img_back, 192, 0, NOTSRCERASE);
putimage((xx - 1) * 64, (yy - 1) * 64, 64, 64, &img_picture, 192, 0, SRCINVERT);
}
}
}
if ((tmp.map[y][x + 1] == 2 && tmp.vis1[y][x + 1] == 0) || (tmp.map[y][x + 1] == 4 && tmp.vis[y][x + 1] == 0)) {
putimage((x - 1) * 64, (y - 1) * 64, 64, 64, &img_back, 128, 0, NOTSRCERASE);
putimage((x - 1) * 64, (y - 1) * 64, 64, 64, &img_picture, 128, 0, SRCINVERT);
if (tmp.map[y][x] == 4) {
putimage((x - 1) * 64 + 16, (y - 1) * 64 + 16, 32, 32, &img_back, 0, 384, NOTSRCERASE);
putimage((x - 1) * 64 + 16, (y - 1) * 64 + 16, 32, 32, &img_picture, 0, 384, SRCINVERT);
tmp.vis[y][x] = 0;
}
tmp.position_x++;
x++;
if (tmp.map[y][x] == 4) {
tmp.vis[y][x] = 1;
}
putimage((x - 1) * 64 + 13, (y - 1) * 64 + 7, 38, 57, &img_back, 320, 365, NOTSRCERASE);
putimage((x - 1) * 64 + 13, (y - 1) * 64 + 7, 38, 57, &img_picture, 320, 365, SRCINVERT);
}
}
if (input == 27) {
esc = 1;
}
muse_move_flag = 0;
}
}
void init() {
loadimage(&img_wall, ".\\wall.png");
loadimage(&img_picture, ".\\picture.jpg");
loadimage(&img_back, ".\\picture2.jpg");
loadimage(&music_1, ".\\music_1.jpg");
loadimage(&music_2, ".\\music_2.jpg");
loadimage(&music_0, ".\\music_0.jpg");
music = 1;
}
void init1() {
int i, j;
int cnt = 0;
memset(check[1].map, 0, sizeof(check[1].map));
memset(check[1].vis, 0, sizeof(check[1].vis));
memset(check[1].vis1, 0, sizeof(check[1].vis1));
check[1].vis1[4][4] = 1;
check[1].vis1[5][4] = 1;
check[1].vis1[6][5] = 1;
check[1].vis1[4][6] = 1;
check[1].box[++cnt].position_x = 4;
check[1].box[cnt].position_y = 4;
check[1].box[++cnt].position_x = 4;
check[1].box[cnt].position_y = 5;
check[1].box[++cnt].position_x = 5;
check[1].box[cnt].position_y = 6;
check[1].box[++cnt].position_x = 6;
check[1].box[cnt].position_y = 4;
check[1].cnt = cnt;
for (i = 3; i <= 5; i++)check[1].map[1][i] = 1;
check[1].map[2][3] = 1;
check[1].map[2][4] = 4;
check[1].map[2][5] = 1;
check[1].map[3][3] = 1;
check[1].map[3][4] = 2;
for (i = 5; i <= 8; i++)check[1].map[3][i] = 1;
for (i = 1; i <= 3; i++)check[1].map[4][i] = 1;
check[1].map[4][4] = 2;//
check[1].map[4][5] = 2;
check[1].map[4][6] = 2;//;
check[1].map[4][7] = 4;
check[1].map[4][8] = 1;
for (i = 1; i <= 8; i++)check[1].map[5][i] = 1;
check[1].map[5][2] = 4;
check[1].map[5][3] = 2;
check[1].map[5][4] = 2;//
check[1].map[5][5] = 2;
for (i = 1; i <= 6; i++)check[1].map[6][i] = 1;
check[1].map[6][5] = 2;//
check[1].map[7][4] = 1;
check[1].map[7][5] = 4;
check[1].map[7][6] = 1;
for (i = 4; i <= 6; i++)check[1].map[8][i] = 1;
check[1].position_x = 5;
check[1].position_y = 5;
}
void init2() {
int i, j;
memset(check[2].map, 0, sizeof(check[2].map));
memset(check[2].vis, 0, sizeof(check[2].vis));
memset(check[2].vis1, 0, sizeof(check[2].vis1));
for (i = 5; i <= 9; i++)check[2].map[1][i] = 1;
for (i = 1; i <= 9; i++)check[2].map[2][i] = 1;
for (i = 6; i <= 8; i++)check[2].map[2][i] = 2;
for (i = 1; i <= 9; i++)check[2].map[3][i] = 1;
for (i = 2; i <= 3; i++)check[2].map[3][i] = 2;
for (i = 6; i <= 8; i++)check[2].map[3][i] = 2;
for (i = 1; i <= 9; i++)check[2].map[4][i] = 1;
for (i = 2; i <= 8; i++)check[2].map[4][i] = 2;
for (i = 1; i <= 9; i++)check[2].map[5][i] = 1;
for (i = 2; i <= 4; i++)check[2].map[5][i] = 2;
for (i = 1; i <= 5; i++)check[2].map[6][i] = 1;
check[2].map[6][4] = 2;
for (i = 2; i <= 7; i++)check[2].map[7][i] = 1;
for (i = 3; i <= 4; i++)check[2].map[7][i] = 2;
for (i = 2; i <= 7; i++)check[2].map[8][i] = 1;
check[2].map[8][3] = 2;
for (i = 4; i <= 6; i++)check[2].map[8][i] = 4;
for (i = 2; i <= 7; i++)check[2].map[9][i] = 1;
int cnt = 0;
check[2].vis1[3][6] = 1;
check[2].vis1[3][7] = 1;
check[2].vis1[4][7] = 1;
check[2].box[++cnt].position_x = 6;
check[2].box[cnt].position_y = 3;
check[2].box[++cnt].position_x = 7;
check[2].box[cnt].position_y = 3;
check[2].box[++cnt].position_x = 7;
check[2].box[cnt].position_y = 4;
check[2].cnt = cnt;
check[2].position_x = 8;
check[2].position_y = 2;
}
void init3() {
int i, j;
memset(check[3].map, 0, sizeof(check[3].map));
memset(check[3].vis, 0, sizeof(check[3].vis));
memset(check[3].vis1, 0, sizeof(check[3].vis1));
for (i = 2; i <= 5; i++)check[3].map[1][i] = 1;
for (i = 1; i <= 7; i++)check[3].map[2][i] = 1;
for (i = 3; i <= 4; i++)check[3].map[2][i] = 2;
for (i = 1; i <= 7; i++)check[3].map[3][i] = 1;
for (i = 2; i <= 3; i++)check[3].map[3][i] = 4;
for (i = 4; i <= 6; i++)check[3].map[3][i] = 2;
for (i = 1; i <= 7; i++)check[3].map[4][i] = 1;
for (i = 2; i <= 3; i++)check[3].map[4][i] = 4;
check[3].map[4][4] = 2;
check[3].map[4][6] = 2;
for (i = 1; i <= 7; i++)check[3].map[5][i] = 1;
check[3].map[5][4] = 2;
check[3].map[5][6] = 2;
for (i = 1; i <= 7; i++)check[3].map[6][i] = 1;
for (i = 2; i <= 4; i++)check[3].map[6][i] = 2;
check[3].map[6][6] = 2;
for (i = 1; i <= 7; i++)check[3].map[7][i] = 1;
for (i = 2; i <= 6; i++)check[3].map[7][i] = 2;
for (i = 1; i <= 7; i++)check[3].map[8][i] = 1;
for (i = 2; i <= 5; i++)check[3].map[8][i] = 2;
for (i = 1; i <= 6; i++)check[3].map[9][i] = 1;
for (i = 4; i <= 5; i++)check[3].map[9][i] = 2;
for (i = 3; i <= 6; i++)check[3].map[10][i] = 1;
int cnt = 0;
check[3].vis1[3][5] = 1;
check[3].vis1[5][4] = 1;
check[3].vis1[7][3] = 1;
check[3].vis1[8][4] = 1;
check[3].box[++cnt].position_x = 5;
check[3].box[cnt].position_y = 3;
check[3].box[++cnt].position_x = 4;
check[3].box[cnt].position_y = 5;
check[3].box[++cnt].position_x = 3;
check[3].box[cnt].position_y = 7;
check[3].box[++cnt].position_x = 4;
check[3].box[cnt].position_y = 8;
check[3].cnt = cnt;
check[3].position_x = 4;
check[3].position_y = 3;
}
void init4() {
int i, j;
memset(check[4].map, 0, sizeof(check[4].map));
memset(check[4].vis, 0, sizeof(check[4].vis));
memset(check[4].vis1, 0, sizeof(check[4].vis1));
for (i = 1; i <= 7; i++)check[4].map[1][i] = 1;
for (i = 1; i <= 8; i++)check[4].map[2][i] = 1;
for (i = 2; i <= 3; i++)check[4].map[2][i] = 4;
check[4].map[2][6] = 2;
for (i = 1; i <= 8; i++)check[4].map[3][i] = 1;
for (i = 3; i <= 7; i++)check[4].map[3][i] = 2;
check[4].map[3][2] = 4;
for (i = 1; i <= 8; i++)check[4].map[4][i] = 1;
for (i = 3; i <= 7; i++)check[4].map[4][i] = 2;
check[4].map[4][2] = 4;
for (i = 1; i <= 8; i++)check[4].map[5][i] = 1;
check[4].map[5][2] = 4;
for (i = 3; i <= 4; i++)check[4].map[5][i] = 2;
for (i = 1; i <= 5; i++)check[4].map[6][i] = 1;
int cnt = 0;
check[4].vis1[3][3] = 1;
check[4].vis1[3][5] = 1;
check[4].vis1[3][6] = 1;
check[4].vis1[4][4] = 1;
check[4].vis1[4][2] = 1;
check[4].vis[4][2] = 1;
check[4].box[++cnt].position_x = 3;
check[4].box[cnt].position_y = 3;
check[4].box[++cnt].position_x = 5;
check[4].box[cnt].position_y = 3;
check[4].box[++cnt].position_x = 6;
check[4].box[cnt].position_y = 3;
check[4].box[++cnt].position_x = 4;
check[4].box[cnt].position_y = 4;
check[4].box[++cnt].position_x = 2;
check[4].box[cnt].position_y = 4;
check[4].cnt = cnt;
check[4].position_x = 6;
check[4].position_y = 2;
}
void init5() {
int i, j;
memset(check[5].map, 0, sizeof(check[5].map));
memset(check[5].vis, 0, sizeof(check[5].vis));
memset(check[5].vis1, 0, sizeof(check[5].vis1));
for (i = 1; i <= 5; i++) {
check[5].map[1][i] = 1;
check[5].map[8][i] = 1;
}
for (i = 1; i <= 8; i++)check[5].map[2][i] = 1;
for (i = 2; i <= 4; i++)check[5].map[2][i] = 4;
for (i = 1; i <= 8; i++)check[5].map[3][i] = 1;
for (i = 2; i <= 3; i++)check[5].map[3][i] = 2;
for (i = 6; i <= 7; i++)check[5].map[3][i] = 2;
for (i = 1; i <= 8; i++)check[5].map[4][i] = 1;
for (i = 2; i <= 7; i++)check[5].map[4][i] = 2;
for (i = 1; i <= 8; i++)check[5].map[5][i] = 1;
for (i = 2; i <= 3; i++)check[5].map[5][i] = 2;
check[5].map[5][6] = 2;
for (i = 1; i <= 8; i++)check[5].map[6][i] = 1;
for (i = 4; i <= 6; i++)check[5].map[6][i] = 2;
check[5].map[6][2] = 2;
for (i = 1; i <= 7; i++)check[5].map[7][i] = 1;
for (i = 2; i <= 4; i++)check[5].map[7][i] = 2;
int cnt = 0;
check[5].vis1[3][3] = 1;
check[5].vis1[4][6] = 1;
check[5].vis1[6][2] = 1;
check[5].box[++cnt].position_x = 3;
check[5].box[cnt].position_y = 3;
check[5].box[++cnt].position_x = 6;
check[5].box[cnt].position_y = 4;
check[5].box[++cnt].position_x = 2;
check[5].box[cnt].position_y = 6;
check[5].cnt = cnt;
check[5].position_x = 6;
check[5].position_y = 3;
}
void init6() {
int i, j;
memset(check[6].map, 0, sizeof(check[6].map));
memset(check[6].vis, 0, sizeof(check[6].vis));
memset(check[6].vis1, 0, sizeof(check[6].vis1));
for (i = 4; i <= 10; i++)check[6].map[1][i] = 1;
for (i = 1; i <= 10; i++)check[6].map[2][i] = 1;
for (i = 5; i <= 9; i++)check[6].map[2][i] = 2;
for (i = 1; i <= 10; i++)check[6].map[3][i] = 1;
for (i = 2; i <= 4; i++)check[6].map[3][i] = 2;
check[6].map[3][5] = 4;
check[6].map[3][9] = 2;
for (j = 4; j <= 10; j++) {
for (i = 1; i <= 11; i++) {
check[6].map[j][i] = 1;
}
}
check[6].map[4][2] = check[6].map[4][4] = 2;
for (i = 6; i <= 9; i++)check[6].map[4][i] = 2;
check[6].map[5][2] = check[6].map[5][10] = 2;
check[6].map[5][9] = 4;
for (i = 4; i <= 7; i++)check[6].map[5][i] = 2;
check[6].map[6][2] = check[6].map[6][10] = 2;
for (i = 4; i <= 8; i++)check[6].map[6][i] = 2;
check[6].map[6][6] = 4;
check[6].map[7][2] = check[6].map[7][10] = 2;
check[6].map[7][3] = 4;
for (i = 5; i <= 8; i++)check[6].map[7][i] = 2;
for (i = 2; i <= 6; i++)check[6].map[8][i] = 2;
check[6].map[8][8] = check[6].map[8][10] = 2;
for (i = 2; i <= 3; i++)check[6].map[9][i] = 2;
check[6].map[9][7] = 4;
for (i = 8; i <= 10; i++)check[6].map[9][i] = 2;
for (i = 2; i <= 7; i++)check[6].map[10][i] = 2;
for (i = 1; i <= 8; i++)check[6].map[11][i] = 1;
for (i = 2; i <= 3; i++)check[6].map[11][i] = 2;
for (i = 1; i <= 4; i++)check[6].map[12][i] = 1;
for (i = 2; i <= 3; i++)check[6].map[12][i] = 2;
for (i = 1; i <= 4; i++)check[6].map[13][i] = 1;
check[6].map[9][2] = check[6].map[8][2] = 1;
int cnt = 0;
check[6].vis1[5][5] = 1;
check[6].vis1[5][7] = 1;
check[6].vis1[6][6] = 1;
check[6].vis1[7][5] = 1;
check[6].vis1[7][7] = 1;
check[6].vis[6][6] = 1;
check[6].box[++cnt].position_x = 5;
check[6].box[cnt].position_y = 5;
check[6].box[++cnt].position_x = 7;
check[6].box[cnt].position_y = 5;
check[6].box[++cnt].position_x = 6;
check[6].box[cnt].position_y = 6;
check[6].box[++cnt].position_x = 5;
check[6].box[cnt].position_y = 7;
check[6].box[++cnt].position_x = 7;
check[6].box[cnt].position_y = 7;
check[6].cnt = cnt;
check[6].position_x = 2;
check[6].position_y = 12;
}
void init7() {
int i, j;
memset(check[7].map, 0, sizeof(check[7].map));
memset(check[7].vis, 0, sizeof(check[7].vis));
memset(check[7].vis1, 0, sizeof(check[7].vis1));
for (i = 1; i <= 9; i++)check[7].map[i][1] = 1;
for (i = 1; i <= 9; i++)check[7].map[i][2] = 1;
for (i = 2; i <= 6; i++)check[7].map[i][2] = 4;
for (i = 7; i <= 8; i++)check[7].map[i][2] = 2;
for (i = 1; i <= 10; i++)check[7].map[i][3] = 1;
for (i = 4; i <= 6; i++)check[7].map[i][3] = 2;
check[7].map[8][3] = 2;
for (i = 3; i <= 10; i++) {
for (j = 4; j <= 8; j++) {
check[7].map[i][j] = 1;
}
}
for (i = 4; i <= 9; i++) {
for (j = 4; j <= 7; j++) {
check[7].map[i][j] = 2;
}
}
for (i = 6; i <= 7; i++)check[7].map[i][4] = 1;
for (i = 6; i <= 7; i++)check[7].map[7][i] = 1;
int cnt = 0;
check[7].vis1[4][5] = 1;
check[7].vis1[5][3] = 1;
check[7].vis1[5][4] = 1;
check[7].vis1[6][5] = 1;
check[7].vis1[8][5] = 1;
check[7].box[++cnt].position_x = 5;
check[7].box[cnt].position_y = 4;
check[7].box[++cnt].position_x = 3;
check[7].box[cnt].position_y = 5;
check[7].box[++cnt].position_x = 4;
check[7].box[cnt].position_y = 5;
check[7].box[++cnt].position_x = 5;
check[7].box[cnt].position_y = 6;
check[7].box[++cnt].position_x = 5;
check[7].box[cnt].position_y = 8;
check[7].cnt = cnt;
check[7].position_x = 7;
check[7].position_y = 9;
}
void init8() {
int i, j;
memset(check[8].map, 0, sizeof(check[8].map));
memset(check[8].vis, 0, sizeof(check[8].vis));
memset(check[8].vis1, 0, sizeof(check[8].vis1));
for (i = 2; i <= 5; i++)check[8].map[1][i] = 1;
for (i = 2; i <= 3; i++)
for (j = 2; j <= 6; j++)
check[8].map[i][j] = 1;
for (i = 1; i <= 3; i++) {
for (j = 3; j <= 5; j++) {
check[8].map[i][j] = 4;
}
}
check[8].map[2][5] = 1;
for (i = 4; i <= 5; i++) {
for (j = 3; j <= 7; j++) {
check[8].map[i][j] = 1;
}
}
for (i = 4; i <= 5; i++) {
for (j = 3; j <= 5; j++) {
check[8].map[i][j] = 2;
}
}
check[8].map[5][6] = 2;
for (i = 6; i <= 9; i++) {
for (j = 1; j <= 7; j++) {
check[8].map[i][j] = 1;
}
}
for (i = 6; i <= 8; i++) {
for (j = 2; j <= 6; j++) {
check[8].map[i][j] = 2;
}
}
check[8].map[6][2] = 1;
check[8].map[6][5] = check[8].map[7][5] = 1;
check[8].map[9][4] = 2;
for (i = 3; i <= 5; i++)check[8].map[10][i] = 1;
for (i = 2; i <= 6; i++)check[8].map[1][i] = 1;
check[8].map[4][2] = check[8].map[5][2] = 1;
int cnt = 0;
check[8].vis1[4][4] = 1;
check[8].vis1[5][3] = 1;
check[8].vis1[5][5] = 1;
check[8].vis1[6][4] = 1;
check[8].vis1[7][3] = 1;
check[8].box[++cnt].position_x = 4;
check[8].box[cnt].position_y = 4;
check[8].box[++cnt].position_x = 3;
check[8].box[cnt].position_y = 5;
check[8].box[++cnt].position_x = 5;
check[8].box[cnt].position_y = 5;
check[8].box[++cnt].position_x = 4;
check[8].box[cnt].position_y = 6;
check[8].box[++cnt].position_x = 3;
check[8].box[cnt].position_y = 7;
check[8].cnt = cnt;
check[8].position_x = 4;
check[8].position_y = 9;
}
不太友好的话 我 的下 载重有完整的 或者直接找一个类似的也行
ps(好烦好烦好烦的一个假期气气死我了)