[C] 纯文本查看 复制代码#include "map.h"
int player[2] = {H / 2, L / 2};
char map[H][L];
int next[4][2] = { {1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int boxNum = 0, boxes[H * L][2], purs[H * L][2];
/*----------------------------------*/
/* 生成地图(newMap)
/*----------------------------------*/
typedef struct listNode{
int x;
int y;
struct listNode *p;
}list;
int wallCheck(int x, int y){
if(map[x][y] != 1)
return map[x][y];
if(map[x + 1][y] + map[x - 1][y] + map[x + 1][y + 1] + map[x - 1][y - 1] +
map[x][y + 1] + map[x][y - 1] + map[x - 1][y + 1] + map[x + 1][y - 1] < 8)
return 1;
return 0;
}
int fullwallCheck(int x, int y){
if(map[x][y] == 2)
return 2;
if(map[x + 1][y] == 2 || map[x - 1][y] == 2 || map[x + 1][y + 1] == 2 || map[x - 1][y - 1] == 2 ||
map[x][y + 1] == 2 || map[x][y - 1] == 2 || map[x - 1][y + 1] == 2 || map[x + 1][y - 1] == 2)
return 1;
return 0;
}
void wallAdd(int x, int y, int direction, int k){
if(abs(x - H / 2) <= 1 && abs(y - L / 2) <= 1) // situation 1: spawn point
return;
if(x =