推箱子程序:
#include
#include
#include
#define U 1
#define D 2
#define L 3
#define R 4 //按键状态,U:上;D:下;L:左R:右
#define ofx 10
#define ofy 9 //x,y方向偏移量
typedef struct MAP //地图
{
int wall[50][2]; //墙
int box[9][2]; //箱子
int des[9][2]; //终点
int overlap[9][2];//箱子与终点的重叠位置
int all,now; //总箱子个数,到位箱子个数
int x,y; //起点
}MAP,*map;
//全局变量//
int player[2]; //玩家位置
int nextp[2],nextb[2]; //玩家下一步位置,箱子下一步位置
MAP Pass[5]; //关卡数组
map Group,p; //关卡数组指针,当前关卡指针
int level; //关卡等级
int status; //玩家状态
int boxc[9][2],overlapc[9][2]; //箱子状态栈,重叠箱子状态栈
int nowbox; //当前到位箱子个数
int regame; //是否重玩
//声明全部函数//
void Pos(int x,int y); //设置光标位置
void welcometogame(); //开始界面
void initgame(); //初始化游戏
void startgame(); //开始游戏
void copybox(int copy[9][2],int b[9][2]); //复制箱子信息
void loadmap(); //加载地图
void printfoverlap(int b[9][2]); //打印重叠箱子位置
void move(); //玩家移动
void trans(int p[2],int q[2]); //状态传递
void inputmap(int a[][2]); //输入地图数据
void gamecircle(); //控制游戏
int main()
{
system("mode con cols=80 lines=30"); //控制台宽度80,高度30