推箱子 C语言程序 报告

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

课程设计设计课题:推箱子程序编写一.课程设计要求

1.初始化模块

2.画图模块

3.移动箱子模块

4.移动小人模块

5.选关模块

二.心得体会

三.设计流程图

四.源程序清单

#include

#include

#include

#include

#include

#include

#include

char ghouse[20][20];

char far *screen=(char far* )0xb8000000;

void putchxy(int y,int x,char ch,char fc,char bc)

{

screen[(x*160)+(y<<1)+0]=ch;

screen[(x*160)+(y<<1)+1]=(bc*16)+fc;

}

/* 定义判断是否胜利的数据结构*/

typedef struct winer {

int x,y;

struct winer *p;

}winer;

/* 箱子位置的数据结构*/

typedef struct boxs {

int x,y;

struct boxs *next;

}boxs;

/* 在特定的坐标上画墙壁并用数组记录状态的函数*/ void printwall(int x,int y)

{

putchxy(y-1,x-1,21,RED,BLACK);

ghouse[x][y]='w';

}

/* 在特定的坐标上画箱子并用数组记录状态的函数*/ void printbox(int x,int y)

{

putchxy(y-1,x-1,9,WHITE,BLACK);

ghouse[x][y]='b';

/* 在特定的坐标上画目的地并用数组记录状态的函数*/

void printwhither1(int x,int y,winer **win,winer **pw)

{

winer *qw;

putchxy(y-1,x-1,'*',GREEN,BLACK);

ghouse[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 printwhither(int x,int y)

{

putchxy(y-1,x-1,'*',GREEN,BLACK);

ghouse[x][y]='m';

}

/* 在特定的坐标上画人的函数*/

void printman(int x,int y)

{

gotoxy(y,x);

_AL=02;_CX=01;_AH=0xa;

geninterrupt(0x10);

}

/* 在特定的坐标上画箱子在目的地上并用数组记录状态的函数*/ void printboxin(int x,int y)

{

putchxy(y-1,x-1,10,GREEN,BLACK);

ghouse[x][y]='i';

}

/* 初始化函数,初始化数组和屏幕*/

void init()

int i,j;

system("cls");

for(i=0;i<20;i++)

for(j=0;j<20;j++)

ghouse[i][j]=0;

_AL=3;

_AH=0;

geninterrupt(0x10);

gotoxy(40,4);

printf("Game Star!");

gotoxy(40,8);

printf("Press up,down,left,right to play."); gotoxy(40,12);

printf("Press Esc to quit it.");

gotoxy(40,10);

printf("Press space to reset the game."); gotoxy(40,6);

printf("You can press 1-3 to chioce the game."); }

/* 第一关的图象初始化*/

winer *inithouse1()

{int x,y;

winer *win=NULL,*pw;

gotoxy(8,3);

printf("Level No.1");

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++)

相关文档
最新文档