该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define MAX 3 /*游戏的总关数*/
#define STEPMAX 3 /*悔棋的最大步数*/
#define Key_R 0x1372
#define Key_Up 0x4800
#define Key_Enter 0x1c0d
#define Key_Down 0x5000
#define Key_P 0x1970
#define Key_Esc 0x11b
#define Key_Right 0x4d00
#define Key_Left 0x4b00
#define BKCOLOR GREEN /*设置背景颜色*/
#define STARTX 40 /*画游戏界面时,二维数组中ghose[0][0]左上角顶点在VGA模式下的横坐标*/
#define STARTY 80 /*画游戏界面时,二维数组中ghose[0][0]左上角顶点在VGA模式下的纵坐标*/
int ghose[10][10]; /*用来表示游戏中各种状态的二维数组*/
int BOXNUM; /*每关中箱子的个数*/
int MISSIONNUM; /*玩家正在玩的关数*/
int Key; /*从键盘读取按键值*/
int STEPNUM; /*人走的步数*/
int DIRECTIONKEY; /*用来记录玩家所按的方向键*/
int BOXMOVE[STEPMAX]; /*记录人行走时箱子移动了没有.如有,BOXMOVE[i]=1,否则BOXMOVE[i]=0*/
int STEP[STEPMAX]; /*记录人行走的方向*/
typedef struct CURRENT
{ int x;
int y;
}PLAYER;
PLAYER p; /*p.x和p.y分别表示人当前所在的横纵坐标*/
typedef struct ADD
{ int x;
int y;
}ADD; /*人行走或悔棋时,用来表示人下一步移动需要增加的横纵坐标值*/
typedef struct STAR
{ int x;
int y;
int c;
} STAR;
STAR s[300]; /*画星星闪动的画面,x,y分别表示每颗星星所在的位置,c表示星星的颜色*/
DRAWSTAR1() /*画星星*/
{int i,j,m,n,dotx,doty,color,maxcolor;
m=getmaxx();
n=getmaxy();
maxcolor=getmaxcolor();
for(i=0;i<300;i++)
{ s[i].x=random(m+1);
s[i].y=random(n+1);
s[i].c=random(maxcolor);
putpixel(s[i].x,s[i].y,s[i].c);}}
DRAWSTAR() /*让星星的坐标不变,颜色变换*/
{int i,j,m,n,dotx,doty,color,maxcolor;
m=getmaxx();
n=getmaxy();
maxcolor=getmaxcolor();
for(i=0;i<300;i++)
{ s[i].x=random(m+1);
s[i].y=random(n+1);
s[i].c=random(maxcolor);
putpixel(s[i].x,s[i].y,s[i].c);
}
do{ for(i=0;i<20000;i++)
delay(2);
for(j=0;j<300;j++)
{
s[j].c=random(maxcolor);
putpixel(s[j].x,s[j].y,s[j].c);}
}while(!bioskey(1));
}
GOOD() /*画火球滚动的画面*/
{void * ptr;
float i;
setactivepage(1);
setcolor(RED);
setfillstyle(1,14);
fillellipse(10,10,10,10);
ptr=malloc(imagesize(0,0,20,20));
getimage(0,0,20,20,ptr);
randomize();
setactivepage(0);
DRAWSTAR1();
for(i=0;i<6.28*4;i=i+0.005)
{putimage(300+8*(cos(i)+i*sin(i)),240+6*(sin(i)-i*cos(i)),ptr,COPY_PUT);
putimage(300+8*(cos(i)+(i)*sin(i)),240+6*(sin(i)-(i)*cos(i)),ptr,COPY_PUT);
if(kbhit()) break;
delay(10);
}
}
void GAME() /*游戏过程的控制*/
{ int i,j,flag;
ADD a;
MISSIONNUM=0;
NEXTMISSION();
do { flag=0;
Key=bioskey(0);
switch(Key)
{ case Key_Enter:{NEXTMISSION();break;}
case Key_Up:{a.x=-1;a.y=0;flag=1;DIRECTIONKEY=Key;break;}
case Key_Down:{a.x=1;a.y=0;flag=1;DIRECTIONKEY=Key;break;}