推箱子(C++)
推箱子C语言程序报告

推箱子C语言程序报告推箱子是一种极富智慧和策略性的游戏,是著名的益智游戏之一、它不仅可以锻炼人们的逻辑思维能力和创造力,而且还能提高人们的解决问题的能力和耐心。
本篇报告将介绍一个基于C语言开发的推箱子游戏,包括游戏规则、程序设计思路和实现效果等方面的内容。
一、游戏规则推箱子游戏的规则十分简单,玩家需要操作一个小人将该场景中的木箱全部推到指定位置。
在游戏开始时,场景中会放置一定数量的木箱和一个小人。
玩家可以通过键盘输入上下左右四个方向键来移动小人,小人可以推动场景中的木箱,但不能直接拉动或推动多个箱子。
当所有的木箱都被推到指定位置时,游戏胜利,反之则失败。
二、程序设计思路推箱子游戏的实现涉及到场景的渲染、小人和木箱的移动、游戏的逻辑判断等多个方面。
下面将分别介绍这些方面的程序设计思路。
1.场景渲染2.小人和木箱的移动玩家操作小人的移动,可以通过监听键盘输入的方向键来实现。
根据输入的方向,判断小人与目标位置的关系,如果目标位置是空地或者指定位置,则小人可以移动到目标位置,否则不能移动。
当小人移动后,如果目标位置是木箱,则需要判断木箱与目标位置的关系,如果目标位置是空地或者指定位置,则木箱可以被推动到目标位置,否则不能推动。
3.游戏逻辑判断在每一次小人移动后,需要判断游戏是否胜利或失败。
胜利的条件是所有的木箱都被推到指定位置,判断的方法是在遍历整个场景时,检查是否存在未推到指定位置的木箱。
失败的条件是小人无法再移动,判断的方法是在判断小人是否能够移动时,如果没有可移动的方向,则游戏失败。
三、实现效果通过以上的程序设计思路,可以开发出一个基于C语言的推箱子游戏。
该游戏可以提供丰富的关卡和难度选择,让玩家能够不断挑战和提高自己的智力。
游戏的界面简洁明了,操作方便快捷,给玩家带来舒适的游戏体验。
总结:推箱子是一种极富智慧的益智游戏,本篇报告介绍了一个基于C语言开发的推箱子游戏。
通过对游戏规则、程序设计思路和实现效果的阐述,可以看出该游戏具有多样化的场景和难度选择,能够锻炼玩家的智力和思维能力。
推箱子的c语言代码

推箱子的c语言代码推箱子(Sokoban)是一种经典的益智游戏,也是计算机程序设计中常用的案例之一。
在这个游戏中,玩家需要移动箱子,将它们推到指定位置上,以完成关卡的目标。
在C语言中,我们可以使用二维数组来表示游戏的地图,其中不同的字符代表不同的元素。
例如,可以使用'#'表示墙壁,'@'表示玩家,'$'表示箱子,'.'表示目标位置。
玩家可以通过控制输入来移动,将箱子推到目标位置上。
为了实现这个游戏,我们可以先定义一个二维数组来表示地图,然后通过循环读取用户的输入,根据输入来移动玩家和箱子,最后判断是否完成了关卡的目标。
我们需要定义一个二维数组来表示地图。
假设地图的大小是10x10,我们可以这样定义:```c#define MAP_SIZE 10char map[MAP_SIZE][MAP_SIZE] = {"##########","# #","# $ #","# @ #","# #","# #","# #","# #","# #","##########"};```其中,'#'表示墙壁,'@'表示玩家,'$'表示箱子,'.'表示目标位置。
空格表示可通行的空地。
接下来,我们可以定义一个函数来打印地图,以便在每一次移动后显示最新的状态:```cvoid printMap() {for (int i = 0; i < MAP_SIZE; i++) {printf("%s\n", map[i]);}}```然后,我们可以定义一个循环,接收用户的输入,并根据输入来移动玩家和箱子。
实验四【程序源码 8-3】推箱子(C版)学生实验讲解

/*实验要求:1.有些方向的移动不能工作,需要根据能工作的进行对比研究后修改,确保四个方向都能正常移动2.计数器工作有故障,需要根据实际效果找到问题解决之3.添加第四关的基础数据并使之在软件开始玩和重新玩中全部承认4.添加栈的机制使得可以在推到墙体时可以后退一步或者数步*///推箱子小游戏C版#include<stdio.h>#include<windows.h>#include<stdlib.h>#include<conio.h>const roomsize=9; //设计房间内部为正方形,边长为9int map[roomsize+2][roomsize+2]; //推箱子房间布局的数据结构:二维数组int data; //记录最短步骤数目int times=0;int array[2]={100,100}; //记录最好成绩char string[30]="正在装入..................";//以下为前几轮游戏房间中细节布局的数据结构:二维数组的实际内容int map1[roomsize+2][roomsize+2]={ //0,1,2,3,4,5,6,7,8,9,10{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, //0{-1,0,0,0,0,1,1,1,1,1,-1}, //1{-1,0,0,0,0,1,0,0,0,1,-1}, //2{-1,1,1,1,0,1,0,0,0,1,-1}, //3{-1,1,2,1,0,1,0,0,0,1,-1}, //4{-1,1,2,1,0,1,0,3,0,1,-1}, //5{-1,1,2,1,1,1,0,3,0,1,-1}, //6{-1,1,0,0,0,0,3,4,0,1,-1}, //7{-1,1,0,0,1,0,0,0,0,1,-1}, //8{-1,1,1,1,1,1,1,1,1,1,-1}, //9{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} //10};int map2[roomsize+2][roomsize+2]={ //0,1,2,3,4,5,6,7,8,9,10{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},//0{-1,0,1,1,1,1,0,0,0,-1,-1}, //1{-1,0,1,4,0,1,1,1,0,-1,-1}, //2{-1,0,1,0,3,0,0,1,0,-1,-1}, //3{-1,1,1,1,0,1,0,1,1,-1,-1}, //4{-1,1,2,1,0,1,0,0,1,-1,-1}, //5{-1,1,2,3,0,0,1,0,1,-1,-1}, //6{-1,1,2,0,0,0,3,0,1,-1,-1}, //7{-1,1,1,1,1,1,1,1,1,-1,-1}, //8{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},//9{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} //10 };int map3[roomsize+2][roomsize+2]={ //0,1,2,3,4,5,6,7,8,9,10{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},//0{-1,1,1,1,1,1,1,1,1,-1,-1}, //1{-1,1,4,0,0,0,1,1,1,-1,-1}, //2{-1,1,0,3,3,0,0,0,1,-1,-1}, //36{-1,1,0,2,1,2,0,0,1,-1,-1}, //4{-1,1,0,0,1,1,3,0,1,-1,-1}, //5{-1,1,0,0,1,1,2,1,1,-1,-1}, //6{-1,1,0,0,0,0,0,1,1,-1,-1}, //7{-1,1,1,1,1,1,1,1,1,-1,-1}, //8{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},//9{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} //10 };//其他关的房间布局模板int map4[roomsize+2][roomsize+2]={ //0,1,2,3,4,5,6,7,8,9,10{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},//0{-1,1,1,1,1,1,1,1,1,-1,-1}, //1{-1,1,0,0,1,0,0,0,1,-1,-1}, //2{-1,1,0,1,0,0,1,0,1,-1,-1}, //3{-1,1,0,0,0,3,1,0,1,-1,-1}, //4{-1,1,1,1,3,0,3,4,1,-1,-1}, //5{-1,1,0,0,0,0,1,0,1,-1,-1}, //6{-1,1,0,2,2,2,0,0,1,-1,-1}, //7{-1,1,1,1,1,1,1,1,1,-1,-1}, //8{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},//9{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} //10};int positionh;//人的位置纵坐标int positionl;//人的位置横坐标int flag;//标志位,记录人在目标位置上int gate;//记录关数int step;//记录步数void initbox();//初始化函数void begin();//开始界面void choose_gate();//选关提示void choose();//游戏时c选项的提示void replay();//重玩void playing();//玩游戏时界面void display();//显示地图void moveleft();//移向左方向void moveright();//移向右方向void movedown();//移向下方向void moveup();//移向上方向void test_flag();//过关提示void record();//成绩排行榜//=====void playing()//Ascii码键盘键位:左为75 右为77 上为72 下为80 {int choice;step=0;printf("开始游戏!");while(1){display();switch(getch()){case 72:moveup();step++;break;case 80:movedown();step++;break;case 75:moveleft();step++;break;case 77:moveright();step++;break;case 'c':case 'C':choose();break;case 'q':case 'Q':printf(" ╭─────────────╮\n");printf(" │是退出游戏还是返回到主界面? │\n");printf(" │ 1. 返回主界面│\n");printf(" │ 2. 退出游戏│\n");printf(" ╰──────────────╯\n");scanf("%d",&choice);switch(choice){case 1:step=0;Sleep(500);system("cls");begin();break;case 2:exit(0);}default:break;}system("cls");}}void display(){printf("\n\n\n\n\n");for(int i=1;i<=roomsize;i++){printf(" ");for(int j=1;j<=roomsize;j++){if(map[i][j]==0) printf(" ");if(map[i][j]==1) printf("■");//墙if(map[i][j]==2) printf("○");//目标位置if(map[i][j]==3) printf("★");//箱子if(map[i][j]==4) printf("☇");//人if(map[i][j]==5) printf("㊣");//箱子在目标位置上}printf("\n");}printf("\n\n");printf("选项(c) 步数:%d\n",step);}void moveright(){if(map[positionh][positionl+1]==0)//向空白位置移动{map[positionh][positionl+1]=4;if(flag==1){ map[positionh][positionl]=2; flag=0; }elsemap[positionh][positionl]=0;positionl++;}else if(map[positionh][positionl+1]==2)//人要到目标位置上{map[positionh][positionl+1]=4;if(flag==1)//人在目标位置上map[positionh][positionl]=2;//恢复目标位置else{map[positionh][positionl]=0;//恢复原来的状态flag=1;//标志位,记录人在目标位置上}positionl++;}else if(map[positionh][positionl+1]==3&&map[positionh][positionl+2]==0)//将箱子推到空白位置上{map[positionh][positionl+2]=3;map[positionh][positionl+1]=4;if(flag==1){ map[positionh][positionl]=2; flag=0; }elsemap[positionh][positionl]=0;positionl++;}else if(map[positionh][positionl+1]==5&&map[positionh][positionl+2]!=1)//要将箱子从目标位置上推出{if(map[positionh][positionl+2]==2)//下一个位置还是目标位置{map[positionh][positionl+2]=5;map[positionh][positionl+1]=4;if(flag==1)map[positionh][positionl]=2;else{ map[positionh][positionl]=0; flag=1; }}else if(map[positionh][positionl+2]==0)//下一个位置是空白{map[positionh][positionl+2]=3;map[positionh][positionl+1]=4;if(flag==1)map[positionh][positionl]=2;else{ map[positionh][positionl]=0; flag=1; }}positionl++;}else if(map[positionh][positionl+1]==3&&map[positionh][positionl+2]==2)//要将箱子推到目标位置上{map[positionh][positionl+2]=5;//箱子在目标位置上map[positionh][positionl+1]=4;if(flag==1)//人在目标位置上{ map[positionh][positionl]=2; flag=0; }else //人不在目标位置上map[positionh][positionl]=0;positionl++;}else step--;//抵消人不动的情况test_flag();}void moveleft(){if(map[positionh][positionl-1]==0)//向空白位置移动{map[positionh][positionl-1]=4;if(flag==1){ map[positionh][positionl]=2; flag=0; }elsemap[positionh][positionl]=0;positionl--;}else if(map[positionh][positionl-1]==2)//人要到目标位置上{map[positionh][positionl-1]=4;if(flag==1)//人在目标位置上map[positionh][positionl]=2;//恢复目标位置else{map[positionh][positionl]=0;//恢复原来的状态flag=1;//标志位,记录人在目标位置上}positionl--;}else if(map[positionh][positionl-1]==3&&map[positionh][positionl-2]==0)//将箱子推到空白位置上{map[positionh][positionl-2]=3;map[positionh][positionl-1]=4;if(flag==1){ map[positionh][positionl]=2; flag=0; }elsemap[positionh][positionl]=0;positionl--;}else if(map[positionh][positionl-1]==5&&map[positionh][positionl-2]!=1)//要将箱子从目标位置上推出{if(map[positionh][positionl-2]==2)//下一个位置还是目标位置{map[positionh][positionl-2]=5;map[positionh][positionl-1]=4;if(flag==1)map[positionh][positionl]=2;else{ map[positionh][positionl]=0; flag=1; }}else if(map[positionh][positionl-2]==0)//下一个位置是空白{map[positionh][positionl-2]=3;map[positionh][positionl-1]=4;if(flag==1)map[positionh][positionl]=2;else{ map[positionh][positionl]=0; flag=1; }}positionl--;}else if(map[positionh][positionl-1]==3&&map[positionh][positionl-2]==2)//要将箱子推到目标位置上{map[positionh][positionl-2]=5;//箱子在目标位置上map[positionh][positionl-1]=4;if(flag==1)//人在目标位置上{ map[positionh][positionl]=2; flag=0; }else //人不在目标位置上map[positionh][positionl]=0;positionl--;}else step--;//抵消人不动的情况test_flag();}void moveup(){if(map[positionh-1][positionl]==0){map[positionh-1][positionl]=4;if(flag==1){ map[positionh][positionl]=2; flag=0; }elsemap[positionh][positionl]=0;positionh--;}else if(map[positionh-1][positionl]==2)//人要到目标位置上{map[positionh-1][positionl]=4;if(flag==1)map[positionh][positionl]=2;//恢复目标位置else{map[positionh][positionl]=0;//恢复原来的状态flag=1;//标志位,记录人在目标位置上}positionh--;}else if(map[positionh-1][positionl]==3&&map[positionh-2][positionl]==0)//将箱子推到空白位置上{map[positionh-2][positionl]=3;map[positionh-1][positionl]=4;if(flag==1){ map[positionh][positionl]=2; flag=0; }elsemap[positionh][positionl]=0;positionh--;}else if(map[positionh-1][positionl]==5&&map[positionh-2][positionl]!=1)//要将箱子从目标位置上推出{if(map[positionh-2][positionl]==2)//下一个位置还是目标位置{map[positionh-2][positionl]=5;map[positionh-1][positionl]=4;if(flag==1)map[positionh][positionl]=2;else{ map[positionh][positionl]=0;flag=1; }}else if(map[positionh-2][positionl]==0)//下一个位置是空白{map[positionh-2][positionl]=3;map[positionh-1][positionl]=4;if(flag==1)map[positionh][positionl]=2;else{ map[positionh][positionl]=0;flag=1; }}positionh--;}else if(map[positionh-1][positionl]==3&&map[positionh-2][positionl]==2)//要将箱子推到目标位置上{map[positionh-2][positionl]=5;//箱子在目标位置上map[positionh-1][positionl]=4;if(flag==1)//人在目标位置上{ map[positionh][positionl]=2;flag=0; }else //人不在目标位置上map[positionh][positionl]=0;positionh--;}else step--;//抵消人不动的情况test_flag();}void movedown(){if(map[positionh+1][positionl]==0){map[positionh+1][positionl]=4;if(flag==1){ map[positionh][positionl]=2; flag=0; }elsemap[positionh][positionl]=0;positionh++;}else if(map[positionh+1][positionl]==2)//人要到目标位置上{map[positionh+1][positionl]=4;if(flag==1)map[positionh][positionl]=2;//恢复目标位置else{map[positionh][positionl]=0;//恢复原来的状态flag=1;//标志位,记录人在目标位置上}positionh++;}else if(map[positionh+1][positionl]==3&&map[positionh+2][positionl]==0)//将箱子推到空白位置上{map[positionh+2][positionl]=3;map[positionh+1][positionl]=4;if(flag==1){ map[positionh][positionl]=2; flag=0; }elsemap[positionh][positionl]=0;positionh++;}else if(map[positionh+1][positionl]==5&&map[positionh+2][positionl]!=1)//要将箱子从目标位置上推出{if(map[positionh+2][positionl]==2)//下一个位置还是目标位置{map[positionh+2][positionl]=5;map[positionh+1][positionl]=4;if(flag==1)map[positionh][positionl]=2;else{ map[positionh][positionl]=0;flag=1; }}else if(map[positionh+2][positionl]==0)//下一个位置是空白{map[positionh+2][positionl]=3;map[positionh+1][positionl]=4;if(flag==1)map[positionh][positionl]=2;else{ map[positionh][positionl]=0;flag=1; }}positionh++;else if(map[positionh+1][positionl]==3&&map[positionh+2][positionl]==2)//要将箱子推到目标位置上{map[positionh+2][positionl]=5;//箱子在目标位置上map[positionh+1][positionl]=4;if(flag==1)//人在目标位置上{ map[positionh][positionl]=2;flag=0; }else //人不在目标位置上map[positionh][positionl]=0;positionh++;}else step--;//抵消人不动的情况test_flag();}void initbox()//初始化函数{positionh=0;positionl=0;flag=0;step=0;gate=0;}void begin(){printf(" ╭────────────────────────────────╮\n");printf(" ││\n");printf(" │★☆★推箱子★☆★│\n");printf(" │╭─────╮│\n");printf(" ││游戏简介││\n");printf(" │╰──────╯│\n");printf(" │推箱子游戏:最终目的是操作一个人(☇)将箱子(★)推到目标位置(○)上。
推箱子游戏C语言编码

#include <dos.h>#include <stdio.h>#include <ctype.h>#include <conio.h>#include <bios.h>#include <alloc.h>typedef struct winer{int x,y;struct winer *p;}winer;char status [20][20];char far *printScreen=(char far* )0xB8000000;void putoutChar(int y,int x,char ch,char fc,char bc);void printWall(int x, int y);void printBox(int x, int y);void printBoxDes(int x, int y);void printDestination(int x, int y);void printDestination1(int x,int y,winer **win,winer **pw); void printMan(int x, int y);void init();winer *initStep1();winer *initStep2();winer *initStep3();winer *initStep4();void moveBoxSpacetoSpace(int x ,int y, char a);void moveBoxDestoSpace(int x ,int y, char a) ;void moveBoxSpacetoDes(int x, int y, char a);void moveBoxDestoDes(int x, int y, char a);int judge(int x, int y);void move(int x, int y, char a);void reset(int i);void putoutChar(int y,int x,char ch,char fc,char bc){printScreen[(x*160)+(y<<1)+0]=ch;printScreen[(x*160)+(y<<1)+1]=(bc*16)+fc;}void printWall(int x,int y){putoutChar(y-1,x-1,219,GREEN,BLACK);status[x][y]='w';}void printBox(int x,int y){putoutChar(y-1,x-1,10,WHITE,BLACK);status[x][y]='b';}void printDestination1(int x,int y,winer **win,winer **pw) {winer *qw;putoutChar(y-1,x-1,003,YELLOW,BLACK);status[x][y]='m';if(*win==NULL){*win=*pw=qw=(winer* )malloc(sizeof(winer));(*pw)->x=x;(*pw)->y=y;(*pw)->p=NULL;}else{qw=(winer* )malloc(sizeof(winer));qw->x=x;qw->y=y;(*pw)->p=qw;(*pw)=qw;qw->p=NULL;}}void printDestination(int x,int y){putoutChar(y-1,x-1,003,YELLOW,BLACK);status[x][y]='m';}void printMan(int x,int y){gotoxy(y,x);_AL=02;_CX=01;_AH=0xa;geninterrupt(0x10);}void printBoxDes(int x,int y){putoutChar(y-1,x-1,10,YELLOW,BLACK);status[x][y]='i';}void init(){int i,j;for(i=0;i<20;i++)for(j=0;j<20;j++)status[i][j]=0;_AL=3;_AH=0;geninterrupt(0x10);gotoxy(41,4);printf(" --------- up");gotoxy(41,6);printf(" --------- down");gotoxy(41,8);printf(" --------- left");gotoxy(41,10);printf(" --------- right");gotoxy(40,12);printf("Space ----- reset");gotoxy(40,14);printf("Esc ------- quit");gotoxy(18,24);printf("CopyRight: 2008 LuoFuxing");gotoxy(40,4);_CX=01;_AH=0xa;_AL=24;geninterrupt(0x10);gotoxy(40,6);_CX=01;_AH=0xa;_AL=25;geninterrupt(0x10);gotoxy(40,8);_CX=01;_AH=0xa;_AL=27;geninterrupt(0x10);gotoxy(40,10);_CX=01;_AH=0xa;_AL=26;geninterrupt(0x10);}winer *initStep1(){int x;int y;winer *win=NULL;winer *pw;gotoxy(25,2);printf("Level 1");for(x=1,y=5;y<=9;y++)printWall(x+4,y+10);for(y=5,x=2;x<=5;x++)printWall(x+4,y+10);for(y=9,x=2;x<=5;x++)printWall(x+4,y+10);for(y=1,x=3;x<=8;x++)printWall(x+4,y+10);for(x=3,y=3;x<=5;x++)printWall(x+4,y+10);for(x=5,y=8;x<=9;x++)printWall(x+4,y+10);for(x=7,y=4;x<=9;x++)printWall(x+4,y+10);for(x=9,y=5;y<=7;y++)printWall(x+4,y+10);for(x=8,y=2;y<=3;y++)printWall(x+4,y+10);printWall(5+4,4+10);printWall(5+4,7+10);printWall(3+4,2+10);printBox(3+4,6+10);printBox(3+4,7+10);printBox(4+4,7+10);printDestination1(4+4,2+10,&win,&pw);printDestination1(5+4,2+10,&win,&pw);printDestination1(6+4,2+10,&win,&pw);printMan(2+4,8+10);return win;}winer *initStep2(){int x;int y;winer *win=NULL;winer *pw;gotoxy(25,2);printf("Level 2");for(x=1,y=4;y<=7;y++)printWall(x+4,y+10);for(x=2,y=2;y<=4;y++)printWall(x+4,y+10);for(x=2,y=7;x<=4;x++)printWall(x+4,y+10);for(x=4,y=1;x<=8;x++)printWall(x+4,y+10);for(x=8,y=2;y<=8;y++)printWall(x+4,y+10);for(x=4,y=8;x<=8;x++)printWall(x+4,y+10);for(x=4,y=6;x<=5;x++)printWall(x+4,y+10);for(x=3,y=2;x<=4;x++)printWall(x+4,y+10);for(x=4,y=4;x<=5;x++)printWall(x+4,y+10);printWall(6+4,3+10);printBox(3+4,5+10);printBox(6+4,6+10);printBox(7+4,3+10);printDestination1(5+4,7+10,&win,&pw);printDestination1(6+4,7+10,&win,&pw);printDestination1(7+4,7+10,&win,&pw);printMan(2+4,6+10);return win;}winer *initStep3(){int x;int y;winer *win=NULL;winer *pw;gotoxy(25,2);printf("Level 3");for(x=1,y=2;y<=8;y++)printWall(x+4,y+10);for(x=2,y=2;x<=4;x++)printWall(x+4,y+10);for(x=4,y=1;y<=3;y++)printWall(x+4,y+10);for(x=5,y=1;x<=8;x++)printWall(x+4,y+10);for(x=8,y=2;y<=5;y++)printWall(x+4,y+10);for(x=5,y=5;x<=7;x++)printWall(x+4,y+10);for(x=7,y=6;y<=9;y++)printWall(x+4,y+10);for(x=3,y=9;x<=6;x++)printWall(x+4,y+10);for(x=3,y=6;y<=8;y++)printWall(x+4,y+10);printWall(2+4,8+10);printWall(5+4,7+10);printBox(6+4,3+10);printBox(4+4,4+10);printBox(5+4,6+10);printDestination1(2+4,5+10,&win,&pw);printDestination1(2+4,6+10,&win,&pw);printDestination1(2+4,7+10,&win,&pw);printMan(2+4,4+10);return win;}winer *initStep4(){int x;int y;winer *win=NULL;winer *pw;gotoxy(23,2);printf("The Last Level");for(x=1,y=1;y<=6;y++)printWall(x+4,y+10);for(x=2,y=7;y<=8;y++)printWall(x+4,y+10);for(x=2,y=1;x<=7;x++)printWall(x+4,y+10);for(x=7,y=2;y<=4;y++)printWall(x+4,y+10);for(x=6,y=4;y<=9;y++)printWall(x+4,y+10);for(x=3,y=9;x<=5;x++)printWall(x+4,y+10);for(x=3,y=3;y<=4;y++)printWall(x+4,y+10);printWall(3+4,8+10);printBox(3+4,5+10);printBox(4+4,4+10);printBox(4+4,6+10);printBox(5+4,5+10);printBox(5+4,3+10);printDestination1(3+4,7+10,&win,&pw);printDestination1(4+4,7+10,&win,&pw);printDestination1(5+4,7+10,&win,&pw);printDestination1(4+4,8+10,&win,&pw);printDestination1(5+4,8+10,&win,&pw);printMan(2+4,2+10);return win;}void moveBoxSpacetoSpace(int x,int y,char a) {switch(a){case 'u':status[x-1][y]=0;printf(" ");printBox(x-2,y);printMan(x-1,y);status[x-2][y]='b';break;case 'd':status[x+1][y]=0;printf(" ");printBox(x+2,y);status[x+2][y]='b';break;case 'l':status[x][y-1]=0;printf(" ");printBox(x,y-2);printMan(x,y-1);status[x][y-2]='b';break;case 'r':status[x][y+1]=0;printf(" ");printBox(x,y+2);printMan(x,y+1);status[x][y+2]='b';break;default:break;}}void moveBoxDestoSpace(int x,int y,char a) {switch(a){case 'u':status[x-1][y]='m';printf(" ");printBox(x-2,y);printMan(x-1,y);status[x-2][y]='b';break;case 'd':status[x+1][y]='m';printf(" ");printBox(x+2,y);printMan(x+1,y);status[x+2][y]='b';break;case 'l':status[x][y-1]='m';printf(" ");printMan(x,y-1);status[x][y-2]='b';break;case 'r':status[x][y+1]='m';printf(" ");printBox(x,y+2);printMan(x,y+1);status[x][y+2]='b';break;default:break;}}void moveBoxSpacetoDes(int x,int y,char a) {switch(a){case 'u':status[x-1][y]=0;printf(" ");printBoxDes(x-2,y);printMan(x-1,y);status[x-2][y]='i';break;case 'd':status[x+1][y]=0;printf(" ");printBoxDes(x+2,y);printMan(x+1,y);status[x+2][y]='i';break;case 'l':status[x][y-1]=0;printf(" ");printBoxDes(x,y-2);printMan(x,y-1);status[x][y-2]='i';break;case 'r':status[x][y+1]=0;printf(" ");printBoxDes(x,y+2);printMan(x,y+1);status[x][y+2]='i';break;default:break;}}void moveBoxDestoDes(int x,int y,char a) {switch(a){case 'u':status[x-1][y]='m';printf(" ");printBoxDes(x-2,y);printMan(x-1,y);status[x-2][y]='i';break;case 'd':status[x+1][y]='m';printf(" ");printBoxDes(x+2,y);printMan(x+1,y);status[x+2][y]='i';break;case 'l':status[x][y-1]='m';printf(" ");printBoxDes(x,y-2);printMan(x,y-1);status[x][y-2]='i';break;case 'r':status[x][y+1]='m';printf(" ");printBoxDes(x,y+2);printMan(x,y+1);status[x][y+2]='i';break;default:break;}}int judge(int x,int y){int i;switch(status[x][y]){case 0:i=1;break;case 'w':i=0;break;case 'b':i=2;break;case 'i':i=4;break;case 'm':i=3;break;default:break;}return i;}void move(int x,int y,char a) {switch(a){case 'u':if(!judge(x-1,y)){gotoxy(y,x);break;}else if(judge(x-1,y)==1||judge(x-1,y)==3) {if(judge(x,y)==3){printDestination(x,y);printMan(x-1,y);break;}else{printf(" ");printMan(x-1,y);break;}}else if(judge(x-1,y)==2){if(judge(x-2,y)==1){moveBoxSpacetoSpace(x,y,'u');if(judge(x,y)==3)printDestination(x,y);gotoxy(y,x-1);}else if(judge(x-2,y)==3){moveBoxSpacetoDes(x,y,'u');if(judge(x,y)==3)printDestination(x,y);gotoxy(y,x-1);}elsegotoxy(y,x);break;}else if(judge(x-1,y)==4){if(judge(x-2,y)==1){moveBoxDestoSpace(x,y,'u');if(judge(x,y)==3)printDestination(x,y);gotoxy(y,x-1);}else if(judge(x-2,y)==3){moveBoxDestoDes(x,y,'u');if(judge(x,y)==3)printDestination(x,y);gotoxy(y,x-1);}elsegotoxy(y,x);break;}case 'd':if(!judge(x+1,y)){gotoxy(y,x);break;}else if(judge(x+1,y)==1||judge(x+1,y)==3) {if(judge(x,y)==3){printDestination(x,y);printMan(x+1,y);break;}else{printf(" ");printMan(x+1,y);break;}}else if(judge(x+1,y)==2){if(judge(x+2,y)==1){moveBoxSpacetoSpace(x,y,'d');if(judge(x,y)==3)printDestination(x,y);gotoxy(y,x+1);}else if(judge(x+2,y)==3){moveBoxSpacetoDes(x,y,'d');if(judge(x,y)==3)printDestination(x,y);gotoxy(y,x+1);}elsegotoxy(y,x);break;}else if(judge(x+1,y)==4){if(judge(x+2,y)==1){moveBoxDestoSpace(x,y,'d');if(judge(x,y)==3)printDestination(x,y);gotoxy(y,x+1);}else if(judge(x+2,y)==3){moveBoxDestoDes(x,y,'d');if(judge(x,y)==3)printDestination(x,y);gotoxy(y,x+1);}elsegotoxy(y,x);break;}case 'l':if(!judge(x,y-1)){gotoxy(y,x);break;}else if(judge(x,y-1)==1||judge(x,y-1)==3) {if(judge(x,y)==3){printDestination(x,y);printMan(x,y-1);break;}else{printf(" ");printMan(x,y-1);break;}}else if(judge(x,y-1)==2){if(judge(x,y-2)==1){moveBoxSpacetoSpace(x,y,'l');if(judge(x,y)==3)printDestination(x,y);gotoxy(y-1,x);}else if(judge(x,y-2)==3){moveBoxSpacetoDes(x,y,'l');if(judge(x,y)==3)printDestination(x,y);gotoxy(y-1,x);}elsegotoxy(y,x);break;}else if(judge(x,y-1)==4){if(judge(x,y-2)==1){moveBoxDestoSpace(x,y,'l');if(judge(x,y)==3)printDestination(x,y);gotoxy(y-1,x);}else if(judge(x,y-2)==3){moveBoxDestoDes(x,y,'l');if(judge(x,y)==3)printDestination(x,y);gotoxy(y-1,x);}elsegotoxy(y,x);break;}case 'r':if(!judge(x,y+1)){gotoxy(y,x);break;}else if(judge(x,y+1)==1||judge(x,y+1)==3) {if(judge(x,y)==3){printDestination(x,y);printMan(x,y+1);break;}else{printf(" ");printMan(x,y+1);break;}}else if(judge(x,y+1)==2){if(judge(x,y+2)==1){moveBoxSpacetoSpace(x,y,'r');if(judge(x,y)==3)printDestination(x,y);gotoxy(y+1,x);}else if(judge(x,y+2)==3){moveBoxSpacetoDes(x,y,'r');if(judge(x,y)==3)printDestination(x,y);gotoxy(y+1,x);}elsegotoxy(y,x);break;}else if(judge(x,y+1)==4){if(judge(x,y+2)==1){moveBoxDestoSpace(x,y,'r');if(judge(x,y)==3)printDestination(x,y);gotoxy(y+1,x);}else if(judge(x,y+2)==3){moveBoxDestoDes(x,y,'r');if(judge(x,y)==3)printDestination(x,y);gotoxy(y+1,x);}elsegotoxy(y,x);break;}default:break;}}void reset(int i){switch(i){case 0:init();initStep1();break;case 1:init();initStep2();break;case 2:init();initStep3();break;case 3:init();initStep4();break;default:break;}}void main(){int key;int x;int y;int s;int i=0;winer *win;winer *pw;_AL=3;_AH=0;geninterrupt(0x10);init();win=initStep1();do{_AH=3;geninterrupt(0x10);x=_DH+1;y=_DL+1;while(bioskey(1)==0);key=bioskey(0);switch(key){case 0x4800:move(x,y,'u');break;case 0x5000:move(x,y,'d');break;case 0x4b00:move(x,y,'l');break;case 0x4d00:move(x,y,'r');break;case 0x3920:reset(i);break;default:break;}s=0;pw=win;while(pw){if(status[pw->x][pw->y]=='m')s++;pw=pw->p;}if(s==0){free(win);gotoxy(15,20);printf("congratulate! You have done this step!");getch();i++;switch(i){case 1:init();win=initStep2();break;case 2:init();win=initStep3();break;case 3:init();win=initStep4();break;case 4:gotoxy(15,21);printf("Congratulation! \n");gotoxy(15,22);printf("You have done all the steps, You are very clever!");key=0x011b;getch();break;default:break;}}}while(key!=0x011b);_AL=3;_AH=0;geninterrupt(0x10); }。
c推箱子课程设计

c 推箱子课程设计一、教学目标本课程的教学目标是使学生掌握C语言的基本语法和编程技巧,培养学生独立思考和解决问题的能力,提高学生的创新意识和团队协作能力。
具体分解为以下三个维度:1.知识目标:使学生掌握C语言的基本语法、数据类型、运算符、控制结构、函数、数组和指针等基本概念,理解面向对象编程思想。
2.技能目标:培养学生具备编写C语言程序的能力,能运用C语言解决实际问题,熟练使用C语言编程工具和调试技巧。
3.情感态度价值观目标:培养学生对计算机科学的兴趣和热情,增强学生的自信心和自主学习能力,培养学生的团队协作意识和沟通能力。
二、教学内容本课程的教学内容主要包括C语言的基本语法、数据类型、运算符、控制结构、函数、数组和指针等基本概念,以及面向对象编程思想。
具体安排如下:1.第1-2周:C语言概述、基本语法和数据类型。
2.第3-4周:运算符、控制结构和函数。
3.第5-6周:数组、指针和字符串。
4.第7-8周:面向对象编程(包括类与对象、继承与多态)。
5.第9-10周:综合案例分析和实战。
三、教学方法本课程采用多种教学方法相结合的方式,以激发学生的学习兴趣和主动性:1.讲授法:讲解基本概念、原理和编程技巧。
2.案例分析法:分析实际案例,引导学生运用C语言解决实际问题。
3.实验法:上机编程实践,巩固所学知识。
4.小组讨论法:分组讨论,培养学生的团队协作能力和沟通能力。
四、教学资源本课程所需教学资源包括:1.教材:《C语言程序设计》。
2.参考书:《C Primer Plus》、《C和指针》。
3.多媒体资料:教学PPT、视频教程。
4.实验设备:计算机、编程环境(如Visual Studio、Code::Blocks等)。
5.在线资源:编程、论坛、开源项目等。
五、教学评估本课程的评估方式包括平时表现、作业、考试等,以全面、客观、公正地评价学生的学习成果。
具体评估方式如下:1.平时表现:包括课堂参与度、小组讨论、提问等,占总评的20%。
C语言推箱子源代码推箱子代码完善

#include <stdio.h>#include <stdlib.h>#include <Windows.h>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 U=1,D=2,L=3,R=4; //定义按键状态//int jump;int ofx=10,ofy=9; //定义xy偏移量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 reset;//是否重玩//声明全部函数//void Pos(int x,int y)//设置光标位置{COORD pos;HANDLE hOutput;pos.X=x;pos.Y=y;hOutput=GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleCursorPosition(hOutput,pos);system("color 3B");}void welcometogame()//开始界面{system("title 2017程序设计之推箱子");Pos(28,3);printf("欢迎来到推箱子!");Pos(50,24);printf(" 软件1603 刘刈16110572087\n");Pos(27,9);printf("用↑.↓.←.→控制人物的移动。
推箱子-C语言源码

#include <stdio.h>#include <stdlib.h>//用到system()#include <conio.h>//因为需要用到getch()函数//推箱子_C语言版//写了一下午,第一个C语言游戏终于写好了,想想有点小激动....//蔚蓝之链编写//分享给大家参考下(在看得懂的情况下...),代码写得很凌乱.....,勿喷#define X 20#define Y 20#define REN 2 //表示人#define XIANGZI 3 //箱子#define WEIZHI 4 //箱子要推到的位置#define KONG 0 //空位#define QIANG 1 //墙#define RW 6 //人在箱子要推到的位置上#define XW 5 //箱子在箱子要推到的位置上#define bool short#define false 0#define true 1//数组内部数值表示内容:0表示空位,1表示墙体,2表示人,3表示箱子,4表示箱子要推到的位置,5表示既有箱子又有又位置,6表示既有位置又有人//01,2,3,4符号表示://0 :" " 1:■2:♀3:回4:◎void create_map_arr(int _x,int _y,int (*map_arr)[Y]);//创建地图数组void creata_map(int _x,int _y, int (*map)[Y]);//创建地图,重绘游戏画面void amend_map(int _x,int _y,char key , int (* arr_map)[Y]);//接收输入,修改游戏画面bool is_finish(int _x, int _y,int _total ,int (*arr_map)[Y]);//判断是否完成推箱子(地图x,地图y,总箱子数,地图数组)int main(void){int map_arr[X][Y];//存储地图的二维数组create_map_arr(X,Y,map_arr);//创建数组printf("C语言_推箱子v1.0 蔚蓝之链编写\n\n");printf("控制键:W↑,A←,S↓,D→\n");printf("提示:玩本游戏前请先关闭输入法\n");system("pause");system("cls");while(1){creata_map(X,Y,map_arr);//创建地图,重绘游戏画面if(is_finish(X,Y,2,map_arr) == true){printf("恭喜哦,推箱子完成!\n");system("pause");return 0;}amend_map(X,Y,getch(),map_arr);//接收输入,修改画面system("cls");//清空画面}getchar();return 0;}void create_map_arr (int _x,int _y,int (*map_arr)[Y])//创建地图数组{int x,y;for(x=0;x<_x;x++){for (y=0;y<_y;y++){if(y==0 || x==0 || x==_x-1 || y==_y-1){*(*(map_arr+x)+y) = QIANG;//printf ("■");}else{*(*(map_arr+x)+y) = KONG;//printf (" ");}}//printf("\n");}//这里可以修改箱子创建的位置,人创建的位置及箱子要达到的位置,默认两个箱子*(*(map_arr+3)+7)=REN;//人*(*(map_arr+5)+6)=XIANGZI;//箱子*(*(map_arr+5)+7)=XIANGZI;//箱子*(*(map_arr+1)+8)=WEIZHI;//箱子要推到的位置*(*(map_arr+2)+8)=WEIZHI;//箱子要推到的位置}void creata_map(int _x,int _y, int (*map)[Y])//创建地图(地图数组[][]){int x,y;for(x = 0; x < _x; x++){for (y = 0; y < _y; y++){if (*(*(map + x) + y) == QIANG){printf ("■");}else if(*(*(map + x) + y) == KONG){printf (" ");}else if(*(*(map + x) + y)==REN || *(*(map + x) + y)==RW){printf ("♀");}else if (* (*(map + x) + y)==XIANGZI){printf("□");}else if (*(*(map + x) + y)==WEIZHI){printf("◎");}else if(*(*(map + x) + y) == XW){printf("回");}}printf ("\n");}}//这个函数写的太乱了,自己看着也头大,不过还好,总算完成了^_^void amend_map(int _x,int _y,char key , int (* arr_map)[Y])//移动(地图x,地图y,按键值,地图数组){int x,y;for(x = 0; x < _x; x++){for (y = 0; y < _y; y++){if(*( * (arr_map + x ) + y) == REN || *( * (arr_map + x ) + y) == RW){if(key == 'a' || key == 'A')//←{if (y > 0){if(*(*(arr_map + x) +(y)) == RW)//人在最终位置{if(*( * (arr_map + x ) + (y-1)) == WEIZHI)//人左边还是最终位置{*( * (arr_map + x ) + (y-1)) = RW;*( * (arr_map + x ) + y) = WEIZHI;}else if(*( * (arr_map + x ) + (y-1)) == XIANGZI || *( * (arr_map + x ) + (y-1)) == XW){if(*( * (arr_map + x ) + (y-1)) == XW){if (*( * (arr_map + x ) + (y-2)) == KONG){*( * (arr_map + x ) + (y-2)) = XIANGZI;*( * (arr_map + x ) + (y-1)) = RW;*( * (arr_map + x ) + (y)) = WEIZHI;}else if(*( * (arr_map + x ) + (y-2)) == WEIZHI){*( * (arr_map + x ) + (y-2)) = XW;*( * (arr_map + x ) + (y-1)) = RW;*( * (arr_map + x ) + (y)) = WEIZHI;}}else if(*(*(arr_map + x) + (y - 1)) == XIANGZI ){if (*( * (arr_map + x ) + (y-2)) == KONG){*( * (arr_map + x ) + (y-2)) = XIANGZI;*( * (arr_map + x ) + (y-1)) = REN;*( * (arr_map + x ) + (y)) = WEIZHI;}else if(*( * (arr_map + x ) + (y-2)) == WEIZHI){*( * (arr_map + x ) + (y-2)) = XW;*( * (arr_map + x ) + (y-1)) = REN;*( * (arr_map + x ) + (y)) = WEIZHI;}}}else if(*(*(arr_map + x) + (y - 1)) == KONG){*( * (arr_map + x ) + (y-1)) = REN;*( * (arr_map + x ) + (y)) = WEIZHI;}}else if (*(*(arr_map + x) +(y)) == REN)//人在空位{if(*( * (arr_map + x ) + (y-1)) == WEIZHI)//人左边是最终位置{*( * (arr_map + x ) + (y-1)) = RW;*( * (arr_map + x ) + y) = KONG;}else if(*( * (arr_map + x ) + (y-1)) == XIANGZI || *( * (arr_map + x ) + (y-1)) == XW){if(*( * (arr_map + x ) + (y-1)) == XW){if (*( * (arr_map + x ) + (y-2)) == KONG){*( * (arr_map + x ) + (y-2)) = XIANGZI;*( * (arr_map + x ) + (y-1)) = RW;*( * (arr_map + x ) + (y)) = KONG;}else if(*( * (arr_map + x ) + (y-2)) == WEIZHI){*( * (arr_map + x ) + (y-2)) = XW;*( * (arr_map + x ) + (y-1)) = RW;*( * (arr_map + x ) + (y)) = KONG;}}else if(*(*(arr_map + x) + (y - 1)) == XIANGZI ){if (*( * (arr_map + x ) + (y-2)) == KONG){*( * (arr_map + x ) + (y-2)) = XIANGZI;*( * (arr_map + x ) + (y-1)) = REN;*( * (arr_map + x ) + (y)) = KONG;}else if(*( * (arr_map + x ) + (y-2)) == WEIZHI){*( * (arr_map + x ) + (y-2)) = XW;*( * (arr_map + x ) + (y-1)) = REN;*( * (arr_map + x ) + (y)) = KONG;}}}else if(*(*(arr_map + x) + (y - 1)) == KONG){*( * (arr_map + x ) + (y-1)) = REN;*( * (arr_map + x ) + (y)) = KONG;}}//人在空位ENDelse if (*( * (arr_map + x ) + (y-1)) == XW || *( * (arr_map + x ) + (y-1)) == XIANGZI)//人左边有箱子或箱子在最终位置{if(*( * (arr_map + x ) + (y-1)) == XIANGZI || *( * (arr_map + x ) + (y-1)) == XW){if(*( * (arr_map + x ) + (y-1)) == XW){if (*( * (arr_map + x ) + (y-2)) == KONG){*( * (arr_map + x ) + (y-2)) = XIANGZI;*( * (arr_map + x ) + (y-1)) = RW;*( * (arr_map + x ) + (y)) = KONG;}else if(*( * (arr_map + x ) + (y-2)) == WEIZHI){*( * (arr_map + x ) + (y-2)) = XW;*( * (arr_map + x ) + (y-1)) = RW;*( * (arr_map + x ) + (y)) = KONG;}}else if(*(*(arr_map + x) + (y - 1)) == XIANGZI ){if (*( * (arr_map + x ) + (y-2)) == KONG){*( * (arr_map + x ) + (y-2)) = XIANGZI;*( * (arr_map + x ) + (y-1)) = REN;*( * (arr_map + x ) + (y)) = KONG;}else if(*( * (arr_map + x ) + (y-2)) == WEIZHI){*( * (arr_map + x ) + (y-2)) = XW;*( * (arr_map + x ) + (y-1)) = REN;*( * (arr_map + x ) + (y)) = KONG;}}}}else if(*(*(arr_map + x) + (y-1)) == WEIZHI){*(*(arr_map + x) + (y-1)) = RW;*(*(arr_map + x) + (y)) = KONG;}else if(*(*(arr_map + x) + (y-1)) == KONG){*(*(arr_map + x) + (y-1)) = REN;*(*(arr_map + x) + (y)) = KONG;}}//IF(Y>0)END}//←else if(key == 'd' || key == 'D')//→{if (y < _y){if(*(*(arr_map + x) +(y)) == RW)//人在最终位置{if(*( * (arr_map + x ) + (y+1)) == WEIZHI)//人右边还是最终位置{*( * (arr_map + x ) + (y+1)) = RW;*( * (arr_map + x ) + y) = WEIZHI;}else if(*( * (arr_map + x ) + (y+1)) == XIANGZI || *( * (arr_map + x ) + (y+1)) == XW){if(*( * (arr_map + x ) + (y+1)) == XW){if (*( * (arr_map + x ) + (y+2)) == KONG){*( * (arr_map + x ) + (y+2)) = XIANGZI;*( * (arr_map + x ) + (y+1)) = RW;*( * (arr_map + x ) + (y)) = WEIZHI;}else if(*( * (arr_map + x ) + (y+2)) == WEIZHI){*( * (arr_map + x ) + (y+2)) = XW;*( * (arr_map + x ) + (y+1)) = RW;*( * (arr_map + x ) + (y)) = WEIZHI;}}else if(*(*(arr_map + x) + (y + 1)) == XIANGZI ){if (*( * (arr_map + x ) + (y+2)) == KONG){*( * (arr_map + x ) + (y+2)) = XIANGZI;*( * (arr_map + x ) + (y+1)) = REN;*( * (arr_map + x ) + (y)) = WEIZHI;}else if(*( * (arr_map + x ) + (y+2)) == WEIZHI){*( * (arr_map + x ) + (y+2)) = XW;*( * (arr_map + x ) + (y+1)) = REN;*( * (arr_map + x ) + (y)) = WEIZHI;}}}else if(*(*(arr_map + x) + (y + 1)) == KONG){*( * (arr_map + x ) + (y+1)) = REN;*( * (arr_map + x ) + (y)) = WEIZHI;}}else if (*(*(arr_map + x) +(y)) == REN)//人在空位{if(*( * (arr_map + x ) + (y+1)) == WEIZHI)//人右边是最终位置{*( * (arr_map + x ) + (y+1)) = RW;*( * (arr_map + x ) + y) = KONG;}else if(*( * (arr_map + x ) + (y+1)) == XIANGZI || *( * (arr_map + x ) + (y+1)) == XW){if(*( * (arr_map + x ) + (y+1)) == XW){if (*( * (arr_map + x ) + (y+2)) == KONG){*( * (arr_map + x ) + (y+2)) = XIANGZI;*( * (arr_map + x ) + (y+1)) = RW;*( * (arr_map + x ) + (y)) = KONG;}else if(*( * (arr_map + x ) + (y-2)) == WEIZHI){*( * (arr_map + x ) + (y+2)) = XW;*( * (arr_map + x ) + (y+1)) = RW;*( * (arr_map + x ) + (y)) = KONG;}}else if(*(*(arr_map + x) + (y + 1)) == XIANGZI ){if (*( * (arr_map + x ) + (y+2)) == KONG){*( * (arr_map + x ) + (y+2)) = XIANGZI;*( * (arr_map + x ) + (y+1)) = REN;*( * (arr_map + x ) + (y)) = KONG;}else if(*( * (arr_map + x ) + (y+2)) == WEIZHI){*( * (arr_map + x ) + (y+2)) = XW;*( * (arr_map + x ) + (y+1)) = REN;*( * (arr_map + x ) + (y)) = KONG;}}}else if(*(*(arr_map + x) + (y + 1)) == KONG){*( * (arr_map + x ) + (y+1)) = REN;*( * (arr_map + x ) + (y)) = KONG;}}//人在空位ENDelse if (*( * (arr_map + x ) + (y+1)) == XW || *( * (arr_map + x ) + (y+1)) == XIANGZI)//人右边有箱子或箱子在最终位置{if(*( * (arr_map + x ) + (y+1)) == XIANGZI || *( * (arr_map + x ) + (y+1)) == XW){if(*( * (arr_map + x ) + (y+1)) == XW){if (*( * (arr_map + x ) + (y+2)) == KONG){*( * (arr_map + x ) + (y+2)) = XIANGZI;*( * (arr_map + x ) + (y+1)) = RW;*( * (arr_map + x ) + (y)) = KONG;}else if(*( * (arr_map + x ) + (y+2)) == WEIZHI){*( * (arr_map + x ) + (y+2)) = XW;*( * (arr_map + x ) + (y+1)) = RW;*( * (arr_map + x ) + (y)) = KONG;}}else if(*(*(arr_map + x) + (y + 1)) == XIANGZI ){if (*( * (arr_map + x ) + (y+2)) == KONG){*( * (arr_map + x ) + (y+2)) = XIANGZI;*( * (arr_map + x ) + (y+1)) = REN;*( * (arr_map + x ) + (y)) = KONG;}else if(*( * (arr_map + x ) + (y+2)) == WEIZHI){*( * (arr_map + x ) + (y+2)) = XW;*( * (arr_map + x ) + (y+1)) = REN;*( * (arr_map + x ) + (y)) = KONG;}}}}else if(*(*(arr_map + x) + (y+1)) == WEIZHI){*(*(arr_map + x) + (y+1)) = RW;*(*(arr_map + x) + (y)) = KONG;}else if(*(*(arr_map + x) + (y+1)) == KONG){*(*(arr_map + x) + (y+1)) = REN;*(*(arr_map + x) + (y)) = KONG;}}//IF(Y>0)END}//→else if(key == 'w' || key == 'W')//↑{if (x-1 > 0){if(*(*(arr_map + (x)) +(y)) == RW)//人在最终位置{if(*( * (arr_map + (x-1) ) + (y)) == WEIZHI)//人上边还是最终位置{*( * (arr_map + (x-1) ) + (y)) = RW;*( * (arr_map + (x) ) + y) = WEIZHI;}else if(*( * (arr_map + (x-1) ) + (y)) == XIANGZI || *( * (arr_map + (x-1) ) + (y)) == XW){if(*( * (arr_map + (x-1) ) + (y)) == XW){if (*( * (arr_map + (x-2) ) + (y)) == KONG){*( * (arr_map + (x-2) ) + (y)) = XIANGZI;*( * (arr_map + (x-1) ) + (y)) = RW;*( * (arr_map + (x) ) + (y)) = WEIZHI;}else if(*( * (arr_map + (x-2) ) + (y)) == WEIZHI){*( * (arr_map + (x-2) ) + (y)) = XW;*( * (arr_map + (x-1) ) + (y)) = RW;*( * (arr_map + x ) + (y)) = WEIZHI;}}else if(*(*(arr_map + (x-1)) + (y)) == XIANGZI ){if (*( * (arr_map + (x-2) ) + (y)) == KONG){*( * (arr_map + (x-2) ) + (y)) = XIANGZI;*( * (arr_map + (x-1) ) + (y)) = REN;*( * (arr_map + x ) + (y)) = WEIZHI;}else if(*( * (arr_map + (x-2) ) + (y)) == WEIZHI){*( * (arr_map + (x-2) ) + (y)) = XW;*( * (arr_map + (x-1) ) + (y)) = REN;*( * (arr_map + x ) + (y)) = WEIZHI;}}}else if(*(*(arr_map + (x-1)) + (y)) == KONG){*( * (arr_map + (x-1) ) + (y)) = REN;*( * (arr_map + x ) + (y)) = WEIZHI;}}else if (*(*(arr_map + x) +(y)) == REN)//人在空位{if(*( * (arr_map + (x-1) ) + (y)) == WEIZHI)//人上边是最终位置{*( * (arr_map + (x-1) ) + (y)) = RW;*( * (arr_map + x ) + y) = KONG;}else if(*( * (arr_map + (x-1) ) + (y)) == XIANGZI || *( * (arr_map + (x-1) ) + (y)) == XW)//人上边是箱子或在最终位置的箱子{if(*( * (arr_map + (x-1) ) + (y)) == XW){if (*( * (arr_map + (x-2) ) + (y)) == KONG){*( * (arr_map + (x-2) ) + (y)) = XIANGZI;*( * (arr_map + (x-1) ) + (y)) = RW;*( * (arr_map + x ) + (y)) = KONG;}else if(*( * (arr_map + (x-2) ) + (y)) == WEIZHI){*( * (arr_map + (x-2) ) + (y)) = XW;*( * (arr_map + (x-1) ) + (y)) = RW;*( * (arr_map + x ) + (y)) = KONG;}}else if(*(*(arr_map + (x-1)) + (y)) == XIANGZI ){if (*( * (arr_map + (x-2) ) + (y)) == KONG){*( * (arr_map + (x-2) ) + (y)) = XIANGZI;*( * (arr_map + (x-1) ) + (y)) = REN;*( * (arr_map + x ) + (y)) = KONG;}else if(*( * (arr_map + (x-2) ) + (y)) == WEIZHI){*( * (arr_map + (x-2) ) + (y)) = XW;*( * (arr_map + (x-1) ) + (y)) = REN;*( * (arr_map + x ) + (y)) = KONG;}}}else if(*(*(arr_map + (x-1)) + (y)) == KONG){*( * (arr_map + (x-1) ) + (y)) = REN;*( * (arr_map + x ) + (y)) = KONG;}}//人在空位ENDelse if (*( * (arr_map + (x-1) ) + (y)) == XW || *( * (arr_map + (x-1) ) + (y)) == XIANGZI)//人上边有箱子或箱子在最终位置{if(*( * (arr_map + (x-1) ) + (y)) == XIANGZI || *( * (arr_map + (x-1) ) + (y)) == XW){if(*( * (arr_map + (x-1) ) + (y)) == XW){if (*( * (arr_map + (x-2) ) + (y)) == KONG){*( * (arr_map + (x-2) ) + (y)) = XIANGZI;*( * (arr_map + (x-1) ) + (y)) = RW;*( * (arr_map + x ) + (y)) = KONG;}else if(*( * (arr_map + (x-2) ) + (y)) == WEIZHI){*( * (arr_map + (x-2) ) + (y)) = XW;*( * (arr_map + (x-1) ) + (y)) = RW;*( * (arr_map + x ) + (y)) = KONG;}}else if(*(*(arr_map + (x-1)) + (y)) == XIANGZI ){if (*( * (arr_map + (x-2) ) + (y)) == KONG){*( * (arr_map + (x-2) ) + (y)) = XIANGZI;*( * (arr_map + (x-1) ) + (y)) = REN;*( * (arr_map + x ) + (y)) = KONG;}else if(*( * (arr_map + (x-2) ) + (y)) == WEIZHI){*( * (arr_map + (x-2) ) + (y)) = XW;*( * (arr_map + (x-1) ) + (y)) = REN;*( * (arr_map + x ) + (y)) = KONG;}}}}else if(*(*(arr_map + (x-1)) + (y)) == WEIZHI){*(*(arr_map + (x-1)) + (y)) = RW;*(*(arr_map + x) + (y)) = KONG;}else if(*(*(arr_map + (x-1)) + (y)) == KONG){*(*(arr_map + (x-1)) + (y)) = REN;*(*(arr_map + x) + (y)) = KONG;}}//IF(Y>0)END}//↑else if(key == 's' || key == 'S')//↓{if (x < _x+1 > 0){if(*(*(arr_map + (x)) +(y)) == RW)//人在最终位置{if(*( * (arr_map + (x+1) ) + (y)) == WEIZHI)//人下边还是最终位置{*( * (arr_map + (x+1) ) + (y)) = RW;*( * (arr_map + (x) ) + y) = WEIZHI;}else if(*( * (arr_map + (x+1) ) + (y)) == XIANGZI || *( * (arr_map + (x+1) ) + (y)) == XW){if(*( * (arr_map + (x+1) ) + (y)) == XW){if (*( * (arr_map + (x+2) ) + (y)) == KONG){*( * (arr_map + (x+2) ) + (y)) = XIANGZI;*( * (arr_map + (x+1) ) + (y)) = RW;*( * (arr_map + (x) ) + (y)) = WEIZHI;}else if(*( * (arr_map + (x+2) ) + (y)) == WEIZHI){*( * (arr_map + (x+2) ) + (y)) = XW;*( * (arr_map + (x+1) ) + (y)) = RW;*( * (arr_map + x ) + (y)) = WEIZHI;}}else if(*(*(arr_map + (x+1)) + (y)) == XIANGZI ){if (*( * (arr_map + (x+2) ) + (y)) == KONG){*( * (arr_map + (x+2) ) + (y)) = XIANGZI;*( * (arr_map + (x+1) ) + (y)) = REN;*( * (arr_map + x ) + (y)) = WEIZHI;}else if(*( * (arr_map + (x+2) ) + (y)) == WEIZHI){*( * (arr_map + (x+2) ) + (y)) = XW;*( * (arr_map + (x+1) ) + (y)) = REN;*( * (arr_map + x ) + (y)) = WEIZHI;}}}else if(*(*(arr_map + (x+1)) + (y)) == KONG){*( * (arr_map + (x+1) ) + (y)) = REN;*( * (arr_map + x ) + (y)) = WEIZHI;}}else if (*(*(arr_map + x) +(y)) == REN)//人在空位{if(*( * (arr_map + (x+1) ) + (y)) == WEIZHI)//人下边是最终位置{*( * (arr_map + (x+1) ) + (y)) = RW;*( * (arr_map + x ) + y) = KONG;}else if(*( * (arr_map + (x+1) ) + (y)) == XIANGZI || *( * (arr_map + (x+1) ) + (y)) == XW){if(*( * (arr_map + (x+1) ) + (y)) == XW){if (*( * (arr_map + (x+2) ) + (y)) == KONG){*( * (arr_map + (x+2) ) + (y)) = XIANGZI;*( * (arr_map + (x+1) ) + (y)) = RW;*( * (arr_map + x ) + (y)) = KONG;}else if(*( * (arr_map + (x+2) ) + (y)) == WEIZHI){*( * (arr_map + (x+2) ) + (y)) = XW;*( * (arr_map + (x+1) ) + (y)) = RW;*( * (arr_map + x ) + (y)) = KONG;}}else if(*(*(arr_map + (x+1)) + (y)) == XIANGZI ){if (*( * (arr_map + (x+2) ) + (y)) == KONG){*( * (arr_map + (x+2) ) + (y)) = XIANGZI;*( * (arr_map + (x+1) ) + (y)) = REN;*( * (arr_map + x ) + (y)) = KONG;}else if(*( * (arr_map + (x+2) ) + (y)) == WEIZHI){*( * (arr_map + (x+2) ) + (y)) = XW;*( * (arr_map + (x+1) ) + (y)) = REN;*( * (arr_map + x ) + (y)) = KONG;}}}else if(*(*(arr_map + (x+1)) + (y)) == KONG){*( * (arr_map + (x+1) ) + (y)) = REN;*( * (arr_map + x ) + (y)) = KONG;}}//人在空位ENDelse if (*( * (arr_map + (x+1) ) + (y)) == XW || *( * (arr_map + (x+1) ) + (y)) == XIANGZI)//人下边有箱子或箱子在最终位置{if(*( * (arr_map + (x+1) ) + (y)) == XIANGZI || *( * (arr_map + (x+1) ) + (y)) == XW){if(*( * (arr_map + (x+1) ) + (y)) == XW){if (*( * (arr_map + (x+2) ) + (y)) == KONG){*( * (arr_map + (x+2) ) + (y)) = XIANGZI;*( * (arr_map + (x+1) ) + (y)) = RW;*( * (arr_map + x ) + (y)) = KONG;}else if(*( * (arr_map + (x+2) ) + (y)) == WEIZHI){*( * (arr_map + (x+2) ) + (y)) = XW;*( * (arr_map + (x+1) ) + (y)) = RW;*( * (arr_map + x ) + (y)) = KONG;}}else if(*(*(arr_map + (x+1)) + (y)) == XIANGZI ){if (*( * (arr_map + (x+2) ) + (y)) == KONG){*( * (arr_map + (x+2) ) + (y)) = XIANGZI;*( * (arr_map + (x+1) ) + (y)) = REN;*( * (arr_map + x ) + (y)) = KONG;}else if(*( * (arr_map + (x+2) ) + (y)) == WEIZHI){*( * (arr_map + (x+2) ) + (y)) = XW;*( * (arr_map + (x+1) ) + (y)) = REN;*( * (arr_map + x ) + (y)) = KONG;}}}}else if(*(*(arr_map + (x+1)) + (y)) == WEIZHI){*(*(arr_map + (x+1)) + (y)) = RW;*(*(arr_map + x) + (y)) = KONG;}else if(*(*(arr_map + (x+1)) + (y)) == KONG){*(*(arr_map + (x+1)) + (y)) = REN;*(*(arr_map + x) + (y)) = KONG;}}//IF(Y>0)END}//↓return;}}}}bool is_finish(int _x, int _y,int _total ,int (*arr_map)[Y])//判断是否完成推箱子(地图x,地图y,总箱子数,地图数组){int x,y,temp = 0;for (x = 0; x < _x; x++){for (y = 0; y < _y; y++){if (*(*(arr_map+x)+y) == XW){temp++;}}}if (_total == temp){return true;}return false;}。
C语言推箱子课程设计(附报告)

(注:VC运行时,分别新建两个文件BotIt.cpp和Maps.h,再在同一目录下运行其中cpp)代码部分文件“BoxIt.cpp”如下:#include <stdio.h>#include <conio.h>#include <stdlib.h>#include "Maps.h"#define AISLE "" //走廊#define N_AISLE 0#define W ALL "■" //墙壁#define N_W ALL 1#define AIM "※" //未放箱子的目标#define N_AIM 2#define BOX "□" //未在目标位置的箱子#define N_BOX 3#define MAN "♀" //人#define N_MAN 4#define BOX_OK "▢" //■已经在目标位置的箱子[即已放箱子的目标]#define N_BOX_OK 5#define MAN_IN "* "#define N_MAN_IN 6#define ESC 0x1B#define UP 'w'#define DOWN 's'#define LEFT 'a'#define RIGHT 'd'#define RESTART 'r'#define SA VE 'x'#define PF(a) printf("%s",a)struct Point{int x;int y;}man_p;/*小人坐标*///struct Filename{int num;char name[20];}filename[10];//int N;/*存档总人数*/int M;/*关数*/int step;/*步数*/char x;void welcome();void ingame();void playgame(int map[14][16]);/*玩游戏*/void displaymap(int map[14][16]);/*展示当前游戏界面*/void findman(int &a,int &b,int map[14][16]);/*找到小人坐标位置*/unsigned char getKey();/*获得有效按键返回按键值*/int getmap(Point p,int map[14][16]);/*获得点p的地图值*/void moveman(Point man_p,Point manf_p,int X,int Y,int map[14][16]);/*人移动*/ void movebox(Point box_p,Point boxf_p,int map[14][16]);/*移箱子*/int win(int map[14][16]);/*判断当无※时赢*/void choosemap(int map[14][16],int i);/*选关*/void changemap(int map[14][16],int mapx[14][16]);/*换地图*/void save();/*保存当前*/int read();/*读取存档*/int a=0,b=0,c=0,d=0;//system("color a");int main(){x='0';while(x!='4'){welcome();if(x=='3'&&read()==0) continue;if(x!='4') ingame();}return 0;}void displaymap(int map[14][16]){int i,j;system("cls");printf("\t\t\tMisson %d\n\n",M);for(i=0;i<14;i++){for(j=0;j<16;j++){ switch(map[i][j]){case N_AISLE:PF(" ");break;case N_W ALL:PF(W ALL);break;case N_AIM:PF(AIM);break;case N_BOX:PF(BOX);break;case N_MAN:PF(MAN);break;case N_BOX_OK:PF(BOX_OK);break;case N_MAN_IN:PF(MAN_IN);default:;}}if(i==2) printf("Press the key:");if(i==3) printf("'w'、'a'、's'、'd' to control ♀");if(i==5) printf("'r' to replay");if(i==7) printf("'x' to save");if(i==9) printf("'ESC' back to the menu");if(i==12) printf("Step:%d",step);PF("\n");}}void playgame(int map[14][16]){ int X,Y;Point manf_p,manff_p;//findman(man_p.x,man_p.y,map);displaymap(map);step=0;while(win(map)==0){findman(man_p.x,man_p.y,map);//printf("输入:");switch(getKey()){case DOWN://printf("\n下\n");manf_p.x=man_p.x;manff_p.x=man_p.x;manf_p.y=man_p.y+1,manff_p.y=man_p.y+2;X=0,Y=1;break;case UP://printf("\n上\n");manf_p.x=man_p.x;manff_p.x=man_p.x;manf_p.y=man_p.y-1,manff_p.y=man_p.y-2;X=0,Y=-1;break;case LEFT://printf("\n左\n");manf_p.x=man_p.x-1;manff_p.x=man_p.x-2;manf_p.y=man_p.y;manff_p.y=man_p.y;X=-1,Y=0;break;case RIGHT://printf("\n右\n");manf_p.x=man_p.x+1;manff_p.x=man_p.x+2;manf_p.y=man_p.y;manff_p.y=man_p.y;X=1,Y=0;break;case SA VE:save();continue;case RESTART:changemap(map,map0);M--;continue;case ESC:system("cls");changemap(map,map0);M=44;continue;default:;}//printf("\n人位置[%d %d]\n",man_p.y,man_p.x);//printf("\n人前方[%d %d]人前前方[%d %d]\n",manf_p.y,manf_p.x,manff_p.y,manff_p.x);switch(getmap(manf_p,map)){case N_AISLE://0case N_AIM://2moveman(man_p,manf_p,X,Y,map);break;case N_BOX://3case N_BOX_OK://5if(getmap(manff_p,map)==N_AISLE||getmap(manff_p,map)==N_AIM){movebox(manf_p,manff_p,map);moveman(man_p,manf_p,X,Y,map);}break;default:;}displaymap(map);}if(M==42) printf("\n\tCongratulation! Pass All!!!\n\n\n\t");}void findman(int &a,int &b,int map[14][16]){int i,j;for(i=0;i<14;i++)for(j=0;j<16;j++)if(map[i][j]==N_MAN||map[i][j]==N_MAN_IN)a=j,b=i;}unsigned char getKey(){unsigned char key;do{key = getch();}while(key != RESTART && key != ESC && key != LEFT && key != RIGHT && key != UP && key != DOWN && key!='x'&& key!=0x1B &&key!='r');return key;}int getmap(Point p,int map[14][16]){//printf("\n前方值%d\n",map[p.y][p.x]);return map[p.y][p.x];}void moveman(Point man_p,Point manf_p,int X,int Y,int map[14][16]){map[manf_p.y][manf_p.x]=(map[manf_p.y][manf_p.x]==N_AIM||map[manf_p.y][manf_p.x]==N_BOX _OK)?N_MAN_IN:N_MAN;map[man_p.y][man_p.x]=map[man_p.y][man_p.x]==N_MAN_IN?N_AIM:N_AISLE; //printf("\n移动后—小人位置值%d\n",map[manf_p.y][manf_p.x]);//printf("\n移动后—原小人位置值%d\n",map[man_p.y][man_p.x]);man_p.x+=X,man_p.y+=Y;step++;}void movebox(Point box_p,Point boxf_p,int map[14][16]){map[boxf_p.y][boxf_p.x]=map[boxf_p.y][boxf_p.x]==N_AISLE?N_BOX:N_BOX_OK; map[box_p.y][box_p.x]=map[box_p.y][box_p.x]==N_BOX?N_AISLE:N_AIM;}int win(int map[14][16]){int i,j;for(i=0;i<14;i++)for(j=0;j<16;j++)if(map[i][j]==2||map[i][j]==6)return 0;return 1;}void choosemap(int map[14][16],int i){switch(i){case 1:changemap(map,map1);break;case 2:changemap(map,map2);break;case 3:changemap(map,map3);break;case 4:changemap(map,map4);break;case 5:changemap(map,map5);break;case 6:changemap(map,map6);break;case 7:changemap(map,map7);break;case 8:changemap(map,map8);break;case 9:changemap(map,map9);break;case 10:changemap(map,map10);break;case 11:changemap(map,map11);break;case 12:changemap(map,map12);break;case 13:changemap(map,map13);break;case 14:changemap(map,map14);break;case 15:changemap(map,map15);break;case 16:changemap(map,map16);break;case 17:changemap(map,map17);break;case 18:changemap(map,map18);break;case 19:changemap(map,map19);break;case 20:changemap(map,map20);break;case 21:changemap(map,map21);break;case 22:changemap(map,map22);break;case 23:changemap(map,map23);break;case 24:changemap(map,map24);break;case 25:changemap(map,map25);break;case 26:changemap(map,map26);break;case 27:changemap(map,map27);break;case 28:changemap(map,map28);break;case 29:changemap(map,map29);break;case 30:changemap(map,map30);break;case 31:changemap(map,map31);break;case 32:changemap(map,map32);break;case 33:changemap(map,map33);break;case 34:changemap(map,map34);break;case 35:changemap(map,map35);break;case 36:changemap(map,map36);break;case 37:changemap(map,map37);break;case 38:changemap(map,map38);break;case 39:changemap(map,map39);break;case 40:changemap(map,map40);break;case 41:changemap(map,map41);break;case 42:changemap(map,map42);break;default:;}}void changemap(int map[14][16],int mapx[14][16]) {int i,j;for(i=0;i<14;i++)for(j=0;j<16;j++)map[i][j]=mapx[i][j];}void save(){int i,j;FILE *in;/*char filename[10][20];printf("put in the filename:");scanf("%s",filename);*/if((in=fopen("save game","w"))==NULL){printf("cannot open this file\n");exit(0);}for(i=0;i<14;i++)for(j=0;j<16;j++)fwrite(&map[i][j],sizeof(int),1,in);fwrite(&M,sizeof(int),1,in);fwrite(&step,sizeof(int),1,in);printf("\nGame Misson %d saved!\n",M);system("pause");fclose(in);}int read(){int i,j;FILE *out;/*char filename[10][20];printf("put in the filename:");scanf("%s",filename);*/if((out=fopen("save game","r"))==NULL){printf("\ncannot open this file\n");return 0;}else{for(i=0;i<14;i++)for(j=0;j<16;j++)fread(&map[i][j],sizeof(int),1,out);fread(&M,sizeof(int),1,out);fread(&step,sizeof(int),1,out);printf("\nM=%d\n",M);printf("Game read!\n");fclose(out);return 1;}}void welcome(){printf("\t\t ♀Box It \n");printf("\t\t1:New Game.\n\t\t2:Select Misson.\n\t\t3:Read Record.\n\t\t4:Exit Game.\n Choose-- ");switch(x=getch()){case '1':printf("1:");M=1;choosemap(map,M);break;case '2':printf("2:");printf("1-42 Misson to Choose:");scanf("%d",&M);choosemap(map,M);break;case '3':printf("3:");if(read()==1) printf("\n%d misson opened\n",M);break;case '4':printf("4:Exit Game.\n\n"); break;default:printf("Not 1-4\n");}}void ingame(){while(M<43){playgame(map);step=0;M++;choosemap(map,M);}}文件“Maps.h”如下:int map[14][16];int map0[14][16]={{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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14][16]={{1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0}, {1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0}, {1,0,3,3,0,0,0,1,1,1,0,0,0,0,0,0}, {1,0,0,3,0,3,3,3,0,1,1,1,1,1,0,0}, {1,1,0,1,1,0,2,2,2,0,0,0,0,1,1,0}, {0,1,0,1,4,1,2,2,2,1,1,1,3,0,1,0},{1,1,0,1,0,3,2,2,2,3,0,1,0,1,1,0}, {1,0,0,1,1,1,1,1,0,1,1,1,0,1,0,0}, {1,0,0,0,0,0,0,3,0,0,0,3,0,1,0,0}, {1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,0}, {0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, };int map37[14][16]={{0,1,1,1,1,0,0,0,0,0,0,1,1,1,1,0}, {0,1,2,2,1,0,0,0,0,0,0,1,2,2,1,0}, {0,1,2,2,1,1,1,1,1,1,1,1,2,2,1,0}, {0,1,0,3,0,2,2,2,2,2,2,3,2,3,1,0}, {0,1,3,0,3,0,3,0,3,0,3,0,3,0,1,0}, {0,1,0,3,0,3,0,3,4,3,0,3,0,3,1,0}, {0,1,3,0,3,0,3,0,3,0,3,0,3,0,1,0}, {0,1,0,3,0,3,0,3,0,3,0,3,0,3,1,0}, {0,1,3,2,3,2,2,2,2,2,2,0,3,0,1,0}, {0,1,2,2,1,1,1,1,1,1,1,1,2,2,1,0}, {0,1,2,2,1,0,0,0,0,0,0,1,2,2,1,0}, {0,1,1,1,1,0,0,0,0,0,0,1,1,1,1,0},。
C语言实现推箱子Visualc++6.0

C语言实现推箱子Visualc++6.0#include#include#include#include#include#include#include#define qiang 1#define ren 2#define xiang 3#define jia 6#define men 8#define oxiang 9int v[13][17]={0};int fuben[13][17];int num_guan; //现在的关数int num_xiang; //箱子的个数int move_num=0; //人行走的次数int push_num=0; //人推箱子的次数int M[2]; //M[0] 是人所在位置的横坐标M[1]是人所在位置的纵坐标int door[2]; //门所在的坐标int tem=0;int cc;void play();void chushi2();void chushihua_guan1();void chushihua_guan2();void chushihua_guan3();void chushihua_guan4();void chushihua_guan5();void chushihua_guan6();void chushihua_guan7();void chushihua_guan8();void chushihua_guan9();void chushihua_guan10();void chushihua_guan11();void chushihua_guan12();void chushihua_guan13();void chushihua_guan14();void dayin();int control();int wancheng();/**********************************************************主方法******************************************************************* ******/int main(){void jiemian();void shuoming();void xuanguan();void chushi(int nn);void chushi1();int i;char c;chushi1();for(i=0;i<=999;i++){ jiemian();c=getche(); if(c=='1') play();else if(c=='2') xuanguan();else if(c=='3') shuoming();else if(c=='4') break;else system("cls");} }/*************************打印游戏主界面******************************/void jiemian(){printf("\n\n\n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HAN DLE),FOREGROUND_INTENSITY | FOREGROUND_BLUE);printf(" ╭╮ ■ ■ □ □ ◆◆◆◆◆◆◆◆ \n");printf(" ││ ■ ■ □□□□ □□□□ ◆ \n");printf(" ╭─┘└╮ ■ ■■■■ □ ■ □ ■ ◆ ◆ \n");printf(" ╰─┐┌ ■ ■ ■ □ ┏━━━┓ ◆ ◆ \n");printf(" ││ ■ ■■■ □□□□┃┏━┓┃ ◆◆ \n");printf(" ╭─┘└╮ ■ ■ □ ┃┏━┓┃ ┏━━━━◆━━┓\n");printf(" ╰─┐┌╯ ■ ■■■ □□ ┃┏━┓┃ ┗━━━━◆━━┛\n");p rintf(" ╭─┘│ ■ ■ □ □ □┃┗━┛┃ ◆ \n");printf(" ╰──╯ ■■■■■ □ □ □┗━━━┛ ◆◆◆◆◆◆ \n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HAN DLE),FOREGROUND_INTENSITY| FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);printf(" >>1 开始游戏\n\n");printf(" >>2 选择关卡\n\n");printf(" >>3游戏帮助\n\n");printf(" >>4 退出游戏\n\n");}void chushi1(){int i,j;for(i=0;i<=12;i++)for (j=0;j<=16;j++)fuben[i][j]=0;}void chushi2(){int i,j;move_num=0;push_num=0;for(i=0;i<=12;i++)for(j=0;j<=16;j++) {v[i][j]=0;fuben[i][j]=0;}}/*************************游戏规则及说明******************************/void shuoming(){int i;char c;for(i=0;i<=999;i++){system("cls");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HAN DLE),FOREGROUND_INTENSITY| FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);printf("\t\t\t╭───────────╮\n");printf("\t\t\t│ 游戏规则及说明│\n");printf("\t\t\t╰───────────╯\n\n ");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HAN DLE),BACKGROUND_INTENSITY|FOREGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE|FOREGROUND_RED|FOREGROUND_RED);printf("囧");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDL E),FOREGROUND_INTENSITY| FOREGROUND_RED |FOREGROUND_GREEN | FOREGROUND_BLUE);printf(" ");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HAN DLE),FOREGROUND_INTENSITY| FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);printf("别看了,这就是你了,还挺cool的吧,嘿嘿\n\n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HAN DLE),FOREGROUND_INTENSITY | FOREGROUND_INTENSITY);printf(" █ ");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HAN DLE),FOREGROUND_INTENSITY| FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);printf("这个是墙,放心,不是豆腐渣工程,要不你可以去撞撞看,\n");printf(" 你会懂得......\n\n\n");printf(" ■ ");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HAN DLE),FOREGROUND_INTENSITY| FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);printf("这个是箱子,就是要你去推的那个,不要试图一下推两个箱\n");printf(" 子,更不要想推着箱子把墙撞开,没用的...不要沮丧,再免\n");printf(" 费给你一句忠告,要是把箱子推到了死角,呵呵,直接下一\n");printf(" 关吧\n\n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HAN DLE),FOREGROUND_INTENSITY |FOREGROUND_GREEN | FOREGROUND_RED);printf(" ★ ");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY| FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);printf("这里就是箱子们的最终归宿了,箱子要是回不到家,哼哼,\n");printf(" 你自己掂量着办吧。
推箱子(C语言小游戏代码)

#include<stdio.h> #include<stdlib.h>#include<windows.h>#include<conio.h>//打印地图void DrawMap();//设置颜色void SetColor(int nColor);//获取玩家坐标POINT GetGamerPosition();//上void Up();//下void Down();//左void Left();//右void Right();//获取空箱子个数int GetSpareBox();//地图//0:空地;3箱子的目的地4箱子// 6人7箱子与目的地的集合//1:墙壁;9人在箱子的目的地int g_map[2][10][12]={{{0,0,0,0,1,1,1,0,0,0,0,0 },{0,0,0,0,1,3,1,0,0,0,0,0 },{0,0,0,0,1,0,1,1,1,1,1,1 },{1,1,1,1,1,4,0,4,0,0,3,1 },{1,3,0,0,0,4,6,1,1,1,1,1 },{1,1,1,1,1,1,4,1,0,0,0,0 },{0,0,0,0,0,1,0,1,0,0,0,0 },{0,0,0,0,0,1,0,1,0,0,0,0 },{0,0,0,0,0,1,3,1,0,0,0,0 },{0,0,0,0,0,1,1,1,0,0,0,0 },},{{1,1,1,1,1,0,0,0,0,0,0,0 },{1,0,0,0,1,0,1,1,1,0,0,0 },{1,0,4,0,1,0,1,1,1,1,1,1 },{1,0,4,6,1,0,1,0,0,0,3,1 },{1,1,1,4,1,1,1,0,0,0,3,1 },{1,1,1,0,0,0,0,0,0,0,3,1 },{0,1,0,0,0,1,0,0,0,0,0,1 },{0,1,0,0,0,1,0,0,0,0,0,1 },{0,1,0,0,0,1,1,1,1,1,1,1 },{1,1,1,1,1,1,0,0,0,0,0,0 },}};int g_nCurrentLevel = 0;//当前管卡int main(){//设置窗口大小system("mode con cols=26 lines=11");//设置标题//SetConsoLeTitle("推箱子");char nInput = 0;//输入字符while(1){//如果箱子推完了过关if (0==GetSpareBox())g_nCurrentLevel++;//清屏system("cls");//如果没有关卡,那就恭喜你成功通关。
c推箱子游戏课程设计

c 推箱子游戏课程设计一、课程目标知识目标:1. 学生能够理解推箱子游戏的基本规则及背景,掌握游戏中的关键元素,如箱子、目标点、玩家角色等。
2. 学生能够运用方向键等基本操作完成推箱子游戏,并理解游戏中的坐标表示方法。
3. 学生了解并掌握编程语言中的循环、条件判断等基本概念,并能够将其应用于推箱子游戏的解法设计中。
技能目标:1. 学生能够运用逻辑思维和分析能力,规划出推箱子游戏的解题策略,提高问题解决能力。
2. 学生通过编写简单的程序代码,实现推箱子游戏的自动化求解,培养编程实践能力。
3. 学生能够与他人合作交流,共同探讨推箱子游戏的解决方案,提高团队协作能力。
情感态度价值观目标:1. 学生在推箱子游戏的过程中,体会编程的乐趣,激发对计算机科学的兴趣和热情。
2. 学生通过克服游戏中的困难,培养勇于挑战、不怕失败的积极心态。
3. 学生在团队协作中,学会尊重他人意见,培养合作精神,提高人际沟通能力。
课程性质:本课程为信息技术课程,结合趣味游戏,引导学生学习编程知识,培养其逻辑思维和团队协作能力。
学生特点:本课程针对五年级学生设计,该年龄段学生好奇心强,喜欢探索和挑战,具备一定的逻辑思维能力,但注意力集中时间较短。
教学要求:教师应关注学生的个体差异,因材施教,注重培养学生的动手实践能力和团队协作精神。
在教学过程中,以学生为主体,鼓励学生主动探究,激发学生的学习兴趣。
同时,将课程目标分解为具体的学习成果,以便进行教学设计和评估。
二、教学内容1. 推箱子游戏简介:介绍推箱子游戏的起源、发展及其在计算机科学教育中的应用,使学生了解游戏背后的教育意义。
2. 游戏规则与元素:讲解推箱子游戏的基本规则,引导学生认识游戏中的关键元素,如箱子、目标点、玩家角色等,并学会用坐标表示游戏空间。
3. 编程基础:- 循环结构:学习for、while等循环语句,掌握在程序中重复执行某段代码的方法。
- 条件判断:学习if-else等条件语句,学会根据不同条件执行不同操作。
c语言开发推箱子小游戏

目录1 摘要.............................................................. .. (3)1.1设计题目............................................. (3)1.2设计内容.............................................. .. (3)1.3开发工具........................................................ . (3)1.4应用平台....................................................... .. (3)2 详细设计 (3)2.1程序结构...................................................... (3)2.2主要功能..................................................... (4)2.3函数实现..................................................... .. (4)2.4开发日志.................................................... (5)3 程序调试及运行 (5)3.1程序运行结果............................................... .. (6)3.2程序使用说明............................................. . (6)3.3程序开发总结.............................................. (7)4 附件(源程序)........................................... . (7)1 摘要1.1 设计题目推箱子游戏1.2 设计内容推箱子是一款经典的益智小游戏,目的是在训练人的逻辑思考能力。
c语言课程设计推箱子

c语言课程设计 推箱子一、课程目标知识目标:1. 让学生掌握C语言的基本语法和编程结构,特别是数组、循环和条件语句的应用。
2. 使学生理解程序逻辑和算法设计的基本原理,并能将其应用于推箱子游戏的实现中。
3. 帮助学生理解坐标系统和二维数组在表示游戏地图中的应用。
技能目标:1. 培养学生运用C语言编写程序解决实际问题的能力,特别是在逻辑推理和算法实现方面。
2. 提高学生调试程序和解决问题的技巧,通过推箱子游戏的开发,学会逐步测试和优化代码。
3. 增进学生对编程工具的使用,如编译器和调试器,以及版本控制的基本操作。
情感态度价值观目标:1. 培养学生对编程的兴趣和热情,通过完成具有挑战性的推箱子游戏,增强学习C语言的信心和动力。
2. 培养学生的团队合作精神,分组合作完成项目,学会在团队中交流和协作。
3. 增强学生的创新意识和实践能力,鼓励学生尝试不同的解决方案,培养独立思考和问题解决的能力。
课程性质:本课程设计为实践性强的综合课题,结合了C语言编程和游戏设计,旨在通过解决实际问题,提高学生的编程能力和逻辑思维。
学生特点:考虑到学生处于高年级,具备一定的C语言基础,有较强的逻辑思维能力,对编程有较高的兴趣。
教学要求:课程设计需注重理论与实践相结合,强调学生的主动参与和动手实践,注重培养学生的自主学习和问题解决能力。
通过推箱子游戏的实现,将目标分解为具体的学习成果,为教学设计和评估提供明确的方向。
二、教学内容本课程教学内容紧密结合课程目标,确保学生能够系统地掌握C语言编程及相关游戏设计知识。
1. C语言基础语法回顾:包括变量定义、数据类型、运算符、控制结构(如if 语句、循环等)。
- 相关教材章节:第1章至第3章2. 数组和字符串的使用:重点介绍二维数组在表示游戏地图中的应用。
- 相关教材章节:第4章3. 函数的定义与调用:强调模块化编程思想,介绍如何将游戏逻辑分解为多个函数。
- 相关教材章节:第5章4. 算法设计与逻辑推理:介绍推箱子游戏中的算法设计,如深度优先搜索、广度优先搜索等。
推箱子c语言程序代码

推箱子c语言程序代码推箱子游戏是一款益智类游戏,在游戏中需要利用角色推动箱子到指定位置,并通过通关来获得胜利。
在这里,我将为您介绍一个简单的推箱子的C语言程序代码。
首先,我们需要定义一些变量和常量来描述游戏中的元素和状态:```c#include <stdio.h>#include <stdlib.h>#include <conio.h>#include <windows.h>#define ROW 10 //地图行数#define COL 15 //地图列数//定义角色、箱子和目标的符号#define PLAYER 'P'#define BOX '$'#define TARGET '*'#define WALL '#'#define SPACE ' '接下来,我们需要定义一个结构体来表示地图上的每一个位置,包含如下元素:- `type`:表示该位置的类型,可以是空格、墙、箱子、目标或者角色。
- `hasBox`: 表示该位置上是否有箱子,是一个布尔值。
```cstruct Position {char type;bool hasBox;};```- `map`:表示地图,是一个二维数组,每个元素都是一个 `Position` 结构体。
- `playerRow` 和 `playerCol`:表示角色当前的位置。
- `boxRow` 和 `boxCol`:表示当前推动的箱子的位置。
```cint playerRow, playerCol, boxRow, boxCol;Position map[ROW][COL];```接下来,我们需要编写地图的初始化函数。
在这个函数中,我们先将地图上所有的位置都标记为空格,并将所有的箱子标记为 `false`。
然后,我们可以将墙、箱子、目标和角色放置到正确的位置上。
c语言推箱子代码

#i n c l u d e<s t d i o.h> #include <stdlib.h>void map1();void map2();void map3();void show();void move();void main(int argc,char*argv[]){time_t a,b;time(&a);system("color 1E");loop1: {system("cls");//刷屏printf("\n\n\n\n\n\n\t\t\t\t欢迎进入推箱子游戏\n\n\t\t\t\t 请按a b c选择游戏\n\n\t\t\t\t 按 d 键结束");int t=getch();if(t=='d'){printf("\n\t\t\t "); }else{if(t=='a'){map1();goto loop1;}if(t=='b'){map2();goto loop1;}if(t=='c'){map3();goto loop1;}else{printf("\n\n\t\t\t\t 请重新输入:");goto loop1;}}}time(&b);printf("\n\n\n\n\t\t\t\t 游戏总共用时%.3d秒\n\t\t\t ",b-a);getch();//等待读取回车符以结束程序}void map1(){time_t p,q,o;time(&p);int i=4,j=4,m=6,n=2,t=1,k=3; system("cls");//刷屏system("color 2E");int x=1,y=7;char z,a[9][9]={ /*为背景设置初始资料*/ {'#','#','#','#','#','#','#','#','#'},{'#','#','#', 3, 0 , 0 , 0 , 1 ,'#'},{'#','#', 0 , 0 , 0 ,'#', 0 ,'#','#'},{'#', 0 , 0 ,'#', 0 , 0 , 5 , 0 ,'#'},{'#', 0 , 5 , 5 , 3 , 0 , 0 , 0 ,'#'},{'#','#', 0 ,'#', 0 , 0 ,'#','#','#'},{'#','#', 3 , 0 , 0 , 0 ,'#','#','#'},{'#','#','#','#','#','#','#','#','#'},{'#','#','#','#','#','#','#','#','#'}};show(a);//调用输出函数move(a,&x,&y,i,j,m,n,t,k,&z);if(a[i][j]=='!'&&a[m][n]=='!'&&a[t][k]=='!'){system("cls");//刷屏show(a);printf("\t\t\t\t YOU ARE WIN!\n");time(&q);printf("\t\t\t\t\t 用时%.3d秒\n",q-p);printf("\t\t\t\t*******回车重新选择*******\n\t\t\t\t");getch();}else{time(&o);if(z=='d'){return;}if(o-p>30){loop1: system("cls");//刷屏printf("\t\t\t\t时间已过请重新回车选关!");int g=getch();if(g==13)//判断是否为回车符{return;}else{goto loop1;}}system("cls");//刷屏show(a);//调用输出函数goto loop;}}void map2(){time_t p,q,o;time(&p);int i=2,j=1,m=1,n=3,t=4,k=6;system("cls");//刷屏system("color 2E");int x=4,y=1;char z,b[9][9]={ /*为背景设置初始资料*/ {'#','#','#','#','#','#','#','#','#'},{'#','#','#', 3 , 0 ,'#','#','#','#'},{'#', 3 ,'#', 0 , 0 , 0 , 0 ,'#','#'},{'#', 0 , 5 , 0 ,'#','#', 0 , 0 ,'#'},{'#', 1 , 0 , 5 , 0 , 0 , 3 , 0 ,'#'},{'#', 0 , 0 , 0 , 0 , 0 , 0 ,'#','#'},{'#','#','#', 0 , 0 , 5 ,'#','#','#'},{'#','#','#','#', 0 , 0 ,'#','#','#'},{'#','#','#','#','#','#','#','#','#'}};show(b);//调用输出函数move(b,&x,&y,i,j,m,n,t,k,&z);if(b[i][j]=='!'&&b[m][n]=='!'&&b[t][k]=='!'){system("cls");//刷屏show(b);printf("\t\t\t\t YOU ARE WIN!\n");time(&q);printf("\t\t\t\t\t 用时%.3d秒\n",q-p);printf("\t\t\t\t*******回车重新选择*******\n\t\t\t\t");getch();}else{time(&o);if(z=='d'){return;}if(o-p>30){loop1: system("cls");//刷屏printf("\t\t\t\t时间已过请重新回车选关!");int g=getch();if(g==13)//判断是否为回车符{return;}else{goto loop1;}}system("cls");//刷屏show(b);//调用输出函数goto loop;}}void map3(){time_t p,q,o;time(&p);int i=2,j=1,m=6,n=2,t=7,k=6;system("cls");//刷屏system("color 2E");int x=3,y=6;char z,c[9][9]={ /*为背景设置初始资料*/ {'#','#','#','#','#','#','#','#','#'},{'#','#','#','#','#', 0 , 0 , 0 ,'#'},{'#', 3 ,'#', 0 , 0 , 0 , 0 , 0 ,'#'},{'#', 0 , 5 , 0 , 5 ,'#', 1 ,'#','#'},{'#', 0 , 0 , 0 , 0 , 0 , 5 , 0 ,'#'},{'#','#', 0 , 0 , 0 , 0 , 0 , 0 ,'#'},{'#','#', 3 , 0 ,'#', 0 ,'#', 0 ,'#'},{'#','#','#', 0 , 0 , 0 , 3 ,'#','#'},{'#','#','#','#','#','#','#','#','#'} };show(c);//调用输出函数move(c,&x,&y,i,j,m,n,t,k,&z);if(c[i][j]=='!'&&c[m][n]=='!'&&c[t][k]=='!'){system("cls");//刷屏show(c);printf("\t\t\t\t YOU ARE WIN!\n");time(&q);printf("\t\t\t\t\t 用时%.3d秒\n",q-p);printf("\t\t\t\t*******回车重新选择*******\n\t\t\t\t");getch();}else{time(&o);if(z=='d'){return;}if(o-p>30){loop1: system("cls");//刷屏printf("\t\t\t\t时间已过请重新回车选关!");int g=getch();if(g==13)//判断是否为回车符{return;}else{goto loop1;}}system("cls");//刷屏show(c);//调用输出函数goto loop;}}void show(char b[9][9]){printf("\t\t\t\t***************************\n");printf("\t\t\t\t 推箱子游戏");printf("\n\t\t\t\t***************************\n");printf("\t\t\t\t 人:★墙:■\n\t\t\t\t 箱子:◎目的地:□\n\t\t\t\t 按d 键退出游戏\n\t\t\t\t 限时30秒!");printf("\n\t\t\t\t***************************\n");int i;int k;for(i=0;i<9;i++) //使用循环将地图转换输出{printf("\t\t\t\t ");for(k=0;k<9;k++){if(b[i][k]=='#'){printf("■");}else{if(b[i][k]==3){printf("□");}else{if(b[i][k]==5){printf("◎");}else{if(b[i][k]==1){printf("★");}else{if(b[i][k]==0){printf(" ");}else{if(b[i][k]=='!'){printf("⊙");}elseprintf("%c ",b[i][k]);}}}}}}printf("\n");}printf("\t\t\t\t***************************\n");}void move(char c[9][9],int *x,int *y,int X,int Y,int A,int B,int N,int M,char *t){*t=getch();//用getch()得到上下左右键,要调用二次getch(),上键72,下键80,左键75,右键77.if(*t=='d'){}//遇到d返回if(*t==75)//左键{if(c[*x][*y-1]=='#'||c[*x][*y-1]==5&&c[*x][*y-2]==5||c[*x][*y-1]==5&&c[*x][*y-2]=='!'){}//遇到墙或推两个箱子else{if(c[*x][*y-1]=='!')//把箱子推出目的地{if(c[*x][*y-2]!=0){}else{c[*x][*y]=0;*y-=1;c[*x][*y]=1;c[*x][*y-1]=5;}}else{if(c[*x][*y-1]==5&&c[*x][*y-2]!='#')//推箱子{if(c[*x][*y]==c[X][Y]||c[*x][*y]==c[A][B]||c[*x][*y]==c[N][M]) //推着箱子离开目的地{c[*x][*y]=3;*y-=1;c[*x][*y]=1;c[*x][*y-1]=5;}else{c[*x][*y]=0;*y-=1;c[*x][*y]=1;c[*x][*y-1]=5;}}else{if(c[*x][*y-1]==5&&c[*x][*y-2]=='#'){}//推不动箱子else{if(c[*x][*y-1]==c[X][Y]||c[*x][*y-1]==c[A][B]||c[*x][*y-1]==c[N][M])//进到目的地{c[*x][*y]=0;*y-=1;c[*x][*y]=1;}else{if(c[*x][*y]==c[X][Y]||c[*x][*y]==c[A][B]||c[*x][*y]==c[N][M]) //离开目的地{c[*x][*y]=3;*y-=1;c[*x][*y]=1;}else //走到空地{c[*x][*y]=0;*y-=1;c[*x][*y]=1;}}}}}}if(c[X][Y]==5||c[A][B]==5||c[N][M]==5)//箱子推到目的地{c[*x][*y-1]='!';}}if(*t==77)//右键{if(c[*x][*y+1]=='#'||c[*x][*y+1]==5&&c[*x][*y+2]==5||c[*x][*y+1]==5&&c[*x][*y+2]=='!'){}//遇到墙或推两个箱子else{if(c[*x][*y+1]=='!')//把箱子推出目的地{if(c[*x][*y+2]!=0){}else{c[*x][*y]=0;*y+=1;c[*x][*y]=1;c[*x][*y+1]=5;}}else{if(c[*x][*y+1]==5&&c[*x][*y+2]!='#')//推箱子{if(c[*x][*y]==c[X][Y]||c[*x][*y]==c[A][B]||c[*x][*y]==c[N][M]) //推着箱子离开目的地{c[*x][*y]=3;*y+=1;c[*x][*y]=1;c[*x][*y+1]=5;}else{c[*x][*y]=0;*y+=1;c[*x][*y]=1;c[*x][*y+1]=5;}}else{if(c[*x][*y+1]==5&&c[*x][*y+2]=='#'){}//推不动箱子else{if(c[*x][*y+1]==c[X][Y]||c[*x][*y+1]==c[A][B]||c[*x][*y+1]==c[N][M])//进到目的地{c[*x][*y]=0;*y+=1;c[*x][*y]=1;}else{if(c[*x][*y]==c[X][Y]||c[*x][*y]==c[A][B]||c[*x][*y]==c[N][M]) //离开目的地{c[*x][*y]=3;*y+=1;c[*x][*y]=1;}else //走到空地{c[*x][*y]=0;*y+=1;c[*x][*y]=1;}}}}}}if(c[X][Y]==5||c[A][B]==5||c[N][M]==5)//箱子推到目的地{c[*x][*y+1]='!';}}if(*t==72)//上键{if(c[*x-1][*y]=='#'||c[*x-1][*y]==5&&c[*x-2][*y]==5||c[*x-1][*y]==5&&c[*x-2][*y]=='!'){}//遇到墙或推两个箱子else{if(c[*x-1][*y]=='!')//把箱子推出目的地{if(c[*x-2][*y]!=0){}else{c[*x][*y]=0;*x-=1;c[*x][*y]=1;c[*x-1][*y]=5;}}else{if(c[*x-1][*y]==5&&c[*x-2][*y]!='#')//推箱子{if(c[*x][*y]==c[X][Y]||c[*x][*y]==c[A][B]||c[*x][*y]==c[N][M]) //推着箱子离开目的地{c[*x][*y]=3;*x-=1;c[*x][*y]=1;c[*x-1][*y]=5;}else{c[*x][*y]=0;*x-=1;c[*x][*y]=1;c[*x-1][*y]=5;}}else{if(c[*x-1][*y]==5&&c[*x-2][*y]=='#'){}//推不动箱子else{if(c[*x-1][*y]==c[X][Y]||c[*x-1][*y]==c[A][B]||c[*x-1][*y]==c[N][M])//进到目的地{c[*x][*y]=0;*x-=1;c[*x][*y]=1;}else{if(c[*x][*y]==c[X][Y]||c[*x][*y]==c[A][B]||c[*x][*y]==c[N][M]) //离开目的地{c[*x][*y]=3;*x-=1;c[*x][*y]=1;}else //走到空地{c[*x][*y]=0;*x-=1;c[*x][*y]=1;}}}}}}if(c[X][Y]==5||c[A][B]==5||c[N][M]==5)//箱子推到目的地{c[*x-1][*y]='!';}}if(*t==80)//下键{if(c[*x+1][*y]=='#'||c[*x+1][*y]==5&&c[*x+2][*y]==5||c[*x+1][*y]==5&&c[*x+2][*y]=='!'){}//遇到墙或推两个箱子else{if(c[*x+1][*y]=='!')//把箱子推出目的地{if(c[*x+2][*y]!=0){}else{c[*x][*y]=0;*x+=1;c[*x][*y]=1;c[*x+1][*y]=5;}}else{if(c[*x+1][*y]==5&&c[*x+2][*y]!='#')//推箱子{if(c[*x][*y]==c[X][Y]||c[*x][*y]==c[A][B]||c[*x][*y]==c[N][M]) //推着箱子离开目的地{c[*x][*y]=3;*x+=1;c[*x][*y]=1;c[*x+1][*y]=5;}else{c[*x][*y]=0;*x+=1;c[*x][*y]=1;c[*x+1][*y]=5;}}else{if(c[*x+1][*y]==5&&c[*x+2][*y]=='#'){}//推不动箱子else{if(c[*x+1][*y]==c[X][Y]||c[*x+1][*y]==c[A][B]||c[*x+1][*y]==c[N][M])//进到目的地{c[*x][*y]=0;*x+=1;c[*x][*y]=1;}else{if(c[*x][*y]==c[X][Y]||c[*x][*y]==c[A][B]||c[*x][*y]==c[N][M]) //离开目的地{c[*x][*y]=3;*x+=1;c[*x][*y]=1;}else //走到空地{c[*x][*y]=0;*x+=1;c[*x][*y]=1;}}}}}}if(c[X][Y]==5||c[A][B]==5||c[N][M]==5)//箱子推到目的地{c[*x+1][*y]='!';}}}。
推箱子游戏C语言程序

#include"stdio.h"#include"bios.h"#define LEFT 75#define RIGHT 77#define UPPER 72#define DOWN 80#define ESC 27struct Boxss /*定义箱子结构体,其中包含坐标属性*/{int x,y;};union keyboard /*定义读取键盘码的共用体类型*/{unsigned int iKeyInfo;char chKeyBit[2];};int fnGetKey(void) /*定义读取键盘码的函数*/{union keyboard uniKey1; /*定义读取键盘码的共用体变量*/while(bioskey(1)==0); /*检测用户是否按键*/uniKey1.iKeyInfo=bioskey(0); /*读取按键信息*/return(uniKey1.chKeyBit[0]==0?uniKey1.chKeyBit[1]:uniKey1.chKeyBit[0]); /*返回ASCII码或扩充码*/}void main(){int iKey,x=11,y=6,tx=11,ty=6; /*x,y为人物移动后坐标,tx,ty为人物移动前坐标*/struct Boxss Box[4]; /*定义箱子数量*/int chMap[10][10]={ /*用二维数组定义地图*/{0,0,0,0,0,0,0,0,0,0}, /*0表示墙1表示路2表示目标*/{0,1,0,0,0,0,1,1,1,0},{0,1,0,2,0,0,1,0,1,0},{0,1,0,1,0,0,1,0,1,0},{0,1,1,1,0,0,1,0,1,0},{0,1,0,0,0,0,1,0,1,0},{0,1,1,1,1,1,1,0,1,0},{0,1,0,1,0,0,0,0,2,0},{0,2,0,1,1,1,1,2,0,0},{0,0,0,0,0,0,0,0,0,0},};int i,j;Box[0].x=13; /*定义箱子的坐标属性*/Box[1].x=11;Box[2].x=14;Box[3].x=18;Box[0].y=8;Box[1].y=7;Box[2].y=13;Box[3].y=7;while(1) /*反复进行求移动的坐标运算*/{for(i=0;i<10;i++) /*输出新地图(刷新地图)*/{gotoxy(10,5+i);for(j=0;j<10;j++){if(chMap[i][j]==0)printf("#");if(chMap[i][j]==1)printf(" ");if(chMap[i][j]==2)printf("X");}}j=0; /*判断是否所有箱子都在目标坐标上*/for(i=0;i<4;i++)if(chMap[Box[i].y-5][Box[i].x-10]==2)j++;if(j==4) /*如果所有箱子都就位输出"YOU WIN!"退出*/{clrscr();printf("You Win!");break;}for(i=0;i<4;i++) /*在起始(或移动后)的坐标输出箱子*/{gotoxy(Box[i].x,Box[i].y);printf("0");}gotoxy(x,y); /*在起始(或移动后)的坐标输出人*/printf("*\b");tx=x; /*记录本次移动前的坐标*/ty=y;iKey=fnGetKey();if(iKey==LEFT&&chMap[y-5][x-1-10]!=0) /*按读取的按键信息改变坐标如果改变的坐标和墙(0)重合则不改变*/x--;if(iKey==RIGHT&&chMap[y-5][x+1-10]!=0)x++;if(iKey==UPPER&&chMap[y-1-5][x-10]!=0)y--;if(iKey==DOWN&&chMap[y+1-5][x-10]!=0)y++; /*输入ESC退出并输出"YOU LOST"*/if(iKey==ESC){clrscr();printf("You Lost");break;}for(i=0;i<4;i++) /*如果移动后的人的坐标与箱子坐标重合,则改变箱子坐标向前一格*/if(Box[i].x==x&&Box[i].y==y){Box[i].x+=(x-tx);Box[i].y+=(y-ty);if(chMap[Box[i].y-5][Box[i].x-10]==0) /*如果移动后的箱子坐标会出现在墙上,则使箱子坐标和人坐标都返回移动前的值*/{Box[i].x-=(x-tx);Box[i].y-=(y-ty);x=tx;y=ty;}break;}clrscr();}getch();}。
C语言推箱子程序

m[x-a][y-b]=0;}
else if(m[x][y]==3) //人在成功点
{
x+=a;
y+=b;
m[x][y]=3;
m[x+a][y+b]=8;
m[x-a][y-b]=4;
}
}
else if(m[x+a][y+b]==5&&m[x+2*a][y+2*b]==4) //人物前面是成功箱子箱子前面是成功点
printf("⊙");
else if(m[i][j]==4)
printf("□");
else if(m[i][j]==5)
{
count++; //每扫描到一个成功值计数加1
printf("★");}
}
printf("\n");
}
return count;
}
void key() //按键操作
{
char z;
{
x+=a;
y+=b;
m[x][y]=3;
m[x+a][y+b]=5;
m[x-a][y-b]=0;
}
}
void game()
{
m[2][1]=2; //初始化人物模型点
for(;;)
{
prnmap(); //地图打印
key(); //操作指令
move(); //移动判断函数
if(prnmap()==4) //通关条件
{x+=a;
y+=b;
c语言推箱子代码

# i n c l#include <>void map1();void map2();void map3();void show();void move();void main(int argc,char*argv[]){time_t a,b;time(&a);system("color 1E");loop1: {system("cls");d 秒\n\t\t\t getch();d 秒\n",q-p);printf("\t\t\t\t******* 回车u d e < >",b-a);新选择*******\n\t\t\t\t");getch();else{time(&o);if(z=='d'){return;} if(o-p>30){loop1: system("cls");dprintf("\t\t\t\t*******getch();}elsetime(&o);秒\n",q-p);回车重新选择*******\n\t\t\t\t");if(z=='d'){return;}if(o-p>30){loop1: system("cls");d 秒\n",q-p);printf("\t\t\t\t******* 回车重新选择*******\n\t\t\t\t"); getch();}else{time(&o);if(z=='d'){return;if(o-p>30){}loop1: system("cls"); if(*t=='d'){}// 遇到d 返回if(*t==75)// 左键{if(c[*x][*y-1]=='#'||c[*x][*y-1]==5&&c[*x][*y-2]==5||c[*x][*y-1]==5&&c[*x][*y-2]=='!'){}// 遇到墙或推两个箱子else{if(c[*x][*y-1]=='!')// 把箱子推出目的地{if(c[*x][*y-2]!=0){}else{c[*x][*y]=0;*y-=1;c[*x][*y]=1;c[*x][*y-1]=5;}}else{if(c[*x][*y-1]==5&&c[*x][*y-2]!='#')//{if(c[*x][*y]==c[X][Y]||c[*x][*y]==c[A][B] ||c[*x][*y]==c[N][M]) //{c[*x][*y]=3;*y-=1;c[*x][*y]=1;c[*x][*y-1]=5;}elsec[*x][*y]=0;推箱子推着箱子离开目的地{*y-=1;c[*x][*y]=1; *y-=1;c[*x][*y]=1;c[*x][*y-1]=5;}}else{if(c[*x][*y-1]==5&&c[*x][*y-2]=='#'){}//else{if(c[*x][*y-1]==c[X][Y]||c[*x][*y-1]==c[A][B] ||c[*x][*y-1]==c[N][M])// 进到目的地{c[*x][*y]=0;推不动箱子c[*x][*y]=1; } else{if(c[*x][*y]==c[X][Y]||c[*x][*y]==c[A][B]||c[*x][*y]==c[N][M]) //{c[*x][*y]=3;*y-=1;c[*x][*y]=1;}else // 走到空地{c[*x][*y]=0;*y-=1;}}}if(c[X][Y]==5||c[A][B]==5||c[N][M]==5)// 箱子推到目的地离开目的地{c[*x][*y-1]='!';}}if(*t==77)// 右键{if(c[*x][*y+1]=='#'||c[*x][*y+1]==5&&c[*x][*y+2]==5||c[*x][*y+1]==5&&c[*x][*y+2]=='!'){}// 遇到墙或推两个箱子else{if(c[*x][*y+1]=='!')// 把箱子推出目的地{if(c[*x][*y+2]!=0){} else{c[*x][*y]=0;*y+=1;c[*x][*y]=1;c[*x][*y+1]=5;}}else{if(c[*x][*y+1]==5&&c[*x][*y+2]!='#')//推箱子{if(c[*x][*y]==c[X][Y]||c[*x][*y]==c[A][B]c[*x][*y]=3;||c[*x][*y]==c[N][M]) // 推着箱子离开目的地*y+=1;c[*x][*y]=1;c[*x][*y+1]=5;}else{c[*x][*y]=0;*y+=1;c[*x][*y]=1;c[*x][*y+1]=5;}}else{elseif(c[*x][*y+1]==5&&c[*x][*y+2]=='#'){}// 推不动箱子{c[*x][*y]=1;else // 走到空地if(c[*x][*y+1]==c[X][Y]||c[*x][*y+1]==c[A][B] ||c[*x][*y+1]==c[N][M])//{c[*x][*y]=0; *y+=1; c[*x][*y]=1;}else{if(c[*x][*y]==c[X][Y]||c[*x][*y]==c[A][B] ||c[*x][*y]==c[N][M]) // {c[*x][*y]=3; *y+=1;}进到目的地离开目的地{{c[*x][*y]=0;*y+=1;c[*x][*y]=1;}}}}}}if(c[X][Y]==5||c[A][B]==5||c[N][M]==5)// 箱子推到目的地{c[*x][*y+1]='!';}}if(*t==72)// 上键if(c[*x-1][*y]=='#'||c[*x-1][*y]==5&&c[*x-2][*y]==5||c[*x-1][*y]==5&&c[*x-2][*y]=='!'){}//遇到墙或推两个箱子else{if(c[*x-1][*y]=='!')// 把箱子推出目的地{if(c[*x-2][*y]!=0){}else{c[*x][*y]=0;*x-=1;c[*x][*y]=1;c[*x-1][*y]=5;}}else{c[*x-1][*y]=5;}if(c[*x-1][*y]==5&&c[*x-2][*y]!='#')//{if(c[*x][*y]==c[X][Y]||c[*x][*y]==c[A][B] ||c[*x][*y]==c[N][M]) //{c[*x][*y]=3; *x-=1; c[*x][*y]=1; c[*x-1][*y]=5; } else {c[*x][*y]=0; *x-=1; c[*x][*y]=1;推箱子推着箱子离开目的地else{if(c[*x-1][*y]==5&&c[*x-2][*y]=='#'){}//推不动箱子else{if(c[*x-1][*y]==c[X][Y]||c[*x-1][*y]==c[A][B]||c[*x-1][*y]==c[N][M])// 进到目的地{c[*x][*y]=0;*x-=1;c[*x][*y]=1;}else{||c[*x][*y]==c[N][M]) // 离开目的地if(c[*x][*y]==c[X][Y]||c[*x][*y]==c[A][B]{}c[*x][*y]=3;*x-=1;c[*x][*y]=1;}else //{c[*x][*y]=0;*x-=1;c[*x][*y]=1;}}}}}走到空地if(c[X][Y]==5||c[A][B]==5||c[N][M]==5)// 箱子推到目的地c[*x][*y]=0;*x+=1;c[*x-1][*y]='!'; }}if(*t==80)// 下键{if(c[*x+1][*y]=='#'||c[*x+1][*y]==5&&c[*x+2][*y]==5||c[*x+1][*y]==5&&c[*x+2][*y]=='!'){}// else{if(c[*x+1][*y]=='!')// 把箱子推出目的地{if(c[*x+2][*y]!=0){} else{遇到墙或推两个箱子c[*x][*y]=1;c[*x+1][*y]=5;}}else{if(c[*x+1][*y]==5&&c[*x+2][*y]!='#')// {if(c[*x][*y]==c[X][Y]||c[*x][*y]==c[A][B] ||c[*x][*y]==c[N][M]) //{c[*x][*y]=3;*x+=1;c[*x][*y]=1;c[*x+1][*y]=5;} else推箱子推着箱子离开目的地{c[*x][*y]=0;*x+=1;c[*x][*y]=0; *x+=1; c[*x][*y]=1; c[*x+1][*y]=5; }}else{if(c[*x+1][*y]==5&&c[*x+2][*y]=='#'){}// else {if(c[*x+1][*y]==c[X][Y]||c[*x+1][*y]==c[A][B] ||c[*x+1][*y]==c[N][M])// 进到目的地 {推不动箱子c[*x][*y]=1;c[*x][*y]=1;}}else{if(c[*x][*y]==c[X][Y]||c[*x][*y]==c[A][B] ||c[*x][*y]==c[N][M]) // {c[*x][*y]=3; *x+=1; c[*x][*y]=1; }else // 走到空地 {c[*x][*y]=0; *x+=1;离开目的地}}}}if(c[X][Y]==5||c[A][B]==5||c[N][M]==5)//箱子推到目的地{c[*x+1][*y]='!';}}}。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
void play();
void check();
void checko();
void operators);
void tell();
void _();
char t_box[row][col];
{
t_box[i][j]=2;
}
if(i==3&&j==5||i==2&&j==8||i==5&&j==3||i==7&&j==8||i==15&&j==16||i==11&&j==3)
{
t_box[i][j]=1;
}
else if(i==6)
{
cout<<"| 最佳闯关:"<<floo<<"\t|"<<endl;
}
else if(i==8)
{
cout<<"| 上关战绩:"<<afterScore<<"\t|"<<endl;
cout<<"================================================================================";
for(int i=0;i<row;i++)
{
cout<<" | ";
}
else if(i==6)
{
cout<<"| 最佳闯关:"<<floo<<"\t|"<<endl;
}
else if(i==8)
{
cout<<"| 上关战绩:"<<afterScore<<"\t|"<<endl;
{
t_box[i][j]=2;
}
if(i==3&&j==5||i==2&&j==8||i==5&&j==3||i==7&&j==8||i==15&&j==16||i==11&&j==3)
{
t_box[i][j]=1;
for(int i=0;i<row;i++)
{
cout<<" | ";
for(int j=0;j<col;j++)
{
cout<<linShi[i][j]<<" ";
}
if(i==4)
{
cout<<"| 最佳战绩:"<<bestScore<<"\t|"<<endl;
}
else if(i==9)
{
cout<<"| \t\t\t|<T>版权声明"<<endl;
}
else if(i==11)
{
cout<<"| \t\t\t|<B>后退一格"<<endl;
}
else if(i==5)
{
cout<<"| \t\t\t|<Q>获胜说明"<<endl;
}
else if(i==7)
{
cout<<"| \t\t\t|<H>游戏帮助"<<endl;
}
else if(i==6)
{
cout<<"| 最佳闯关:"<<floo<<"\t|"<<endl;
}
else if(i==8)
{
cout<<"| 上关战绩:"<<afterScore<<"\t|"<<endl;
}
if(i==row/2&&j==col/2)
{
t_box[i][j]=12;
}
cout<<t_box[i][j]<<" ";
}
if(i==4)
{
cout<<"| 最佳战绩:"<<bestScore<<"\t|"<<endl;
for(int j=0;j<col;j++)
{
t_box[i][j]='+';
if(i==2&&j==5||i==1&&j==8||i==5&&j==4||i==6&&j==8||i==14&&j==15||i==11&&j==2)
}
else if(i==10)
{
cout<<"| 已走步数:"<<steep<<"\t|"<<endl;
{
cout<<endl;
cout<<"\t\t\t\t 推箱子";
if(floo<set)
{
floo=set;
}
if(set==1)
{
cout<<"<第一关>"<<endl;
{
cout<<"<第四关>"<<endl;
}
else
{
cout<<"<第五关>"<<endl;
}
cout<<"================================================================================";
}
else if(i==5)
{
cout<<"| \t\t\t|<Q>获胜说明"<<endl;
}
else if(i==7)
{
cout<<"| \t\t\t|<H>游戏帮助"<<endl;
}
else
{
cout<<"| \t\t\t|"<<endl;