求一份用C语言编写的俄罗斯方块的源代码!
俄罗斯方块C源代码
#include <stdio.h>
#include <windows.h>
#include <conio.h>
#include <time.h>
#define ZL 4 //坐标增量, 不使游戏窗口靠边
#define WID 36 //游戏窗口的宽度
#define HEI 20 //游戏窗口的高度
int i,j,Ta,Tb,Tc; // Ta,Tb,Tc用于记住和转换方块变量的值
int a[60][60]={0}; //标记游戏屏幕各坐标点:0,1,2分别为空、方块、边框
int b[4]; //标记4个"口"方块:1有,0无,类似开关
int x,y, level,score,speed; //方块中心位置的x,y坐标,游戏等级、得分和游戏速度
int flag,next; //当前要操作的方块类型序号,下一个方块类型序号
void gtxy(int m, int n); //以下声明要用到的自编函数
void gflag( ); //获得下一方块序号
void csh( ); //初始化界面
void start( ); //开始部分
void prfk ( ); //打印方块
void clfk( ); //清除方块
void mkfk( ); //制作方块
void keyD( ); //按键操作
int ifmov( ); //判断方块能否移动或变体
void clHA( ); //清除满行的方块
void clNEXT( ); //清除边框外的NEXT方块
int main( )
{ csh( );
while(1)
{start( ); //开始部分
while(1)
{ prfk( );
Sleep(speed); //延时
clfk( );
Tb=x;Tc=flag; //临存当前x坐标和序号,以备撤销操作
keyD( );
y++; //方块向下移动
if (ifmov( )==0) { y--; prfk( ); dlHA( ); break;} //不可动放下,删行,跨出循环
}
for(i=y-2;i<y+2;i++){ if (i==ZL) { j=0; } } //方块触到框顶
if (j==0) { system("cls");gtxy(10,10);printf("游戏结束!"); getch(); break; }
clNEXT( ); //清除框外的NEXT方块
}
return 0;
}
void gtxy(int m, int n) //控制光标移动
{COORD pos; //定义变量
pos.X = m; //横坐标
pos.Y = n; //纵坐标
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
void csh( ) //初始化界面
{gtxy(ZL+WID/2-5,ZL-2); printf("俄罗斯方块"); //打印游戏名称
gtxy(ZL+WID+3,ZL+7); printf("******* NEXT:"); //打印菜单信息
gtxy(ZL+WID+3,ZL+13); printf("**********");
gtxy(ZL+WID+3,ZL+15); printf("Esc :退出游戏");
gtxy(ZL+WID+3,ZL+17); printf("↑键:变体");
gtxy(ZL+WID+3,ZL+19); printf("空格:暂停游戏");
gtxy(ZL,ZL); printf("╔"); gtxy(ZL+WID-2,ZL); printf("╗"); //打印框角
gtxy(ZL,ZL+HEI); printf("╚"); gtxy(ZL+WID-2,ZL+HEI); printf("╝");
a[ZL][ZL+HEI]=2; a[ZL+WID-2][ZL+HEI]=2; //记住有图案
for(i=2;i<WID-2;i+=2) {gtxy(ZL+i,ZL); printf("═"); } //打印上横框
for(i=2;i<WID-2;i+=2) {gtxy(ZL+i,ZL+HEI); printf("═"); a[ZL+i][ZL+HEI]=2; } //下框
for(i=1;i<HEI;i++) { gtxy(ZL,ZL+i); printf("║"); a[ZL][ZL+i]=2; } //左竖框记住有图案
for(i=1;i<HEI;i++) {gtxy(ZL+WID-2,ZL+i); printf("║"); a[ZL+WID-2][ZL+i]=2; } //右框
CONSOLE_CURSOR_INFO cursor_info={1,0}; //以下是隐藏光标的设置
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
level=1; score=0; speed=400;
gflag( ); flag=next; //获得一个当前方块序号
}
void gflag( ) //获得下一个方块的序号
{ srand((unsigned)time(NULL)); next = rand()%19+1; }
void start( ) //开始部分
{ gflag( ); Ta=flag; flag=next; //保存当前方块序号,将下一方块序号临时操作
x=ZL+WID+6; y=ZL+10; prfk( ); //给x,y赋值,在框外打印出下一方块
flag=Ta; x=ZL+WID/2; y=ZL-1; //取回当前方块序号,并给x,y赋值
}
void prfk ( ) //打印俄罗斯方块
{ for(i=0;i<4;i++) {b[i]=1; } //数组b[4]每个元素的值都为1
mkfk ( ); //制作俄罗斯方块
for( i= x-2; i<=x+4; i+=2 ) //打印方块
{ for(j=y-2;j<= y+1;j++) { if( a[i][j]==1 && j>ZL ){ gtxy(i,j); printf("□"); } } }
gtxy(ZL+WID+3,ZL+1); printf("level : %d",level); //以下打印菜单信息
gtxy(ZL+WID+3,ZL+3); printf("score : %d",score);
gtxy(ZL+WID+3,ZL+5); printf("speed : %d",speed);
}
void clfk( ) //清除俄罗斯方块
{ for(i=0;i<4;i++) { b[i]=0; } //数组b[4]每个元素的值都为0
mkfk ( ); //制作俄罗斯方块
for( i=x-2; i<=x+4; i+=2 ) //清除方块
{ for(j=y-2;j<=y+1;j++){ if( a[i][j]==0 && j>ZL ){ gtxy(i,j); printf(" "); } } }
}
void mkfk( ) //制作俄罗斯方块
{ a[x][ y]=b[0]; //方块中心位置状态: 1-有,0-无
switch(flag) //共6大类,19种小类型
{ case 1: { a[x][y-1]=b[1]; a[x+2][y-1]=b[2]; a[x+2][y]=b[3]; break; } //田字方块
case 2: { a[x-2][y]=b[1]; a[x+2][y]=b[2]; a[x+4][y]=b[3]; break; } //直线方块:----
case 3: { a[x][y-1]=b[1]; a[x][y-2]=b[2]; a[x][y+1]=b[3]; break; } //直线方块: |
case 4: { a[x-2][y]=b[1]; a[x+2][y]=b[2]; a[x][y+1]=b[3]; break; } //T字方块
case 5: { a[x][y-1]=b[1]; a[x][y+1]=b[2]; a[x-2][y]=b[3]; break; } //T字顺时针转90度
case 6: { a[x][y-1]=b[1]; a[x-2][y]=b[2]; a[x+2][y]=b[3]; break; } //T字顺转180度
case 7: { a[x][y-1]=b[1]; a[x][y+1]=b[2]; a[x+2][y]=b[3]; break; } //T字顺转270度
case 8: { a[x][y+1]=b[1]; a[x-2][y]=b[2]; a[x+2][y+1]=b[3]; break; } //Z字方块
case 9: { a[x][y-1]=b[1]; a[x-2][y]=b[2]; a[x-2][y+1]=b[3]; break; } //Z字顺转90度
case 10: { a[x][y-1]=b[1]; a[x-2][y-1]=b[2]; a[x+2][y]=b[3]; break; } //Z字顺转180度
case 11: { a[x][y+1]=b[1]; a[x+2][y-1]=b[2]; a[x+2][ y]=b[3]; break; } //Z字顺转270度
case 12: { a[x][y-1]=b[1]; a[x][y+1]=b[2]; a[x-2][y-1]=b[3]; break; } //7字方块
case 13: {a[x-2][y]=b[1]; a[x+2][y-1]=b[2]; a[x+2][y]=b[3]; break; } //7字顺转90度
case 14: { a[x][y-1]=b[1]; a[x][y+1]=b[2]; a[x+2][y+1]=b[3]; break; } //7字顺转180度
case 15: { a[x-2][y]=b[1]; a[x-2][y+1]=b[2]; a[x+2][y]=b[3]; break; } //7字顺转270度
case 16: { a[x][y+1]=b[1]; a[x][y-1]=b[2]; a[x+2][y-1]=b[3]; break; } //倒7字方块
case 17: { a[x-2][y]=b[1]; a[x+2][y+1]=b[2]; a[x+2][y]=b[3]; break; } //倒7字顺转90度
case 18: { a[x][y-1]=b[1]; a[x][y+1]=b[2]; a[x-2][y+1]=b[3]; break; } //倒7字顺转180度
case 19: { a[x-2][y]=b[1]; a[x-2][y-1]=b[2]; a[x+2][y]=b[3]; break; } //倒7字顺转270度
}
}
void keyD( ) //按键操作
{ if (kbhit( ))
{ int key;
key=getch();
if (key==224)
{ key=getch();
if (key==75) { x-=2; } //按下左方向键,中心横坐标减2
if (key==77) { x+=2; } //按下右方向键,中心横坐标加2
if (key==72) //按下向上方向键,方块变体
{ if (flag>=2 && flag<=3 ) { flag++; flag%=2; flag+=2; }
if ( flag>=4 && flag<=7 ) { flag++; flag%=4; flag+=4; }
if (flag>=8 && flag<=11 ) { flag++; flag%=4; flag+=8; }
if (flag>=12 && flag<=15 ) { flag++; flag%=4; flag+=12; }
if ( flag>=16 && flag<=19 ) { flag++; flag%=4; flag+=16; } }
}
if (key==32) //按空格键,暂停
{ prfk( ); while(1) { if (getch( )==32) { clfk( );break;} } } //再按空格键,继续游戏
if (ifmov( )==0) { x=Tb; flag=Tc; } //如果不可动,撤销上面操作
else { prfk( ); Sleep(speed); clfk( ); Tb=x;Tc=flag;} //如果可动,执行操作
}
}
int ifmov( ) //判断能否移动
{ if (a[x][y]!=0) { return 0; } //方块中心处有图案返回0,不可移动
else{ if ( (flag==1 && ( a[x][ y-1]==0 && a[x+2][y-1]==0 && a[x+2][y]==0 ) ) ||
(flag==2 && ( a[x-2][y]==0 && a[x+2][y]==0 && a[x+4][y]==0 ) ) ||
(flag==3 && ( a[x][y-1]==0 && a[x][y-2]==0 && a[x][y+1]==0 ) ) ||
(flag==4 && ( a[x-2][y]==0 && a[x+2][y]==0 && a[x][y+1]==0 ) ) ||
(flag==5 && ( a[x][y-1]==0 && a[x][y+1]==0 && a[x-2][y]==0 ) ) ||
(flag==6 && ( a[x][ y-1]==0 && a[x-2][y]==0 && a[x+2][y]==0 ) ) ||
(flag==7 && ( a[x][y-1]==0 && a[x][y+1]==0 && a[x+2][y]==0 ) ) ||
(flag==8 && ( a[x][y+1]==0 && a[x-2][y]==0 && a[x+2][y+1]==0 ) ) ||
(flag==9 && ( a[x][y-1]==0 && a[x-2][y]==0 && a[x-2][y+1]==0 ) ) ||
(flag==10 && ( a[x][y-1]==0 && a[x-2][y-1]==0 && a[x+2][y]==0 ) ) ||
(flag==11 && ( a[x][y+1]==0 && a[x+2][y-1]==0 && a[x+2][y]==0 ) ) ||
(flag==12 && ( a[x][y-1]==0 && a[x][y+1]==0 && a[x-2][y-1]==0 ) ) ||
( flag==13 && ( a[x-2][y]==0 && a[x+2][y-1]==0 && a[x+2][y]==0 ) ) ||
( flag==14 && ( a[x][y-1]==0 && a[x][y+1]==0 && a[x+2][y+1]==0 ) ) ||
(flag==15 && ( a[x-2][y]==0 && a[x-2][y+1]==0 && a[x+2][y]==0 ) ) ||
(flag==16 && ( a[x][y+1]==0 && a[x][y-1]==0 && a[x+2][y-1]==0 ) ) ||
( flag==17 && ( a[x-2][y]==0 && a[x+2][y+1]==0 && a[x+2][y]==0 ) ) ||
(flag==18 && ( a[x][y-1]==0 &&a[x][y+1]==0 && a[x-2][y+1]==0 ) ) ||
(flag==19 && ( a[x-2][y]==0 && a[x-2][y-1]==0
&& a[x+2][y]==0 ) ) ) { return 1; }
}
return 0; //其它情况返回0
}
void clNEXT( ) //清除框外的NEXT方块
{ flag = next; x=ZL+WID+6; y=ZL+10; clfk( ); }
void clHA( ) //清除满行的方块
{ int k, Hang=0; //k是某行方块个数, Hang是删除的方块行数
for(j=ZL+HEI-1;j>=ZL+1;j--) //当某行有WID/2-2个方块时,则为满行
{ k=0; for(i=ZL+2;i<ZL+WID-2;i+=2)
{ if (a[i][j]==1) //竖坐标从下往上,横坐标由左至右依次判断是否满行
{ k++; //下面将操作删除行
if (k==WID/2-2) { for(k=ZL+2;k<ZL+WID-2;k+=2)
{ a[k][j]=0; gtxy(k,j); printf(" "); Sleep(1); }
for(k=j-1;k>ZL;k--)
{ for(i=ZL+2;i<ZL+WID-2;i+=2) //已删行数上面有方块,先清除再全部下移一行
{ if(a[i][k]==1) { a[i][k]=0; gtxy(i,k); printf(" ");a[i][k+1]=1;
gtxy(i,k+1); printf("□"); } }
}
j++; //方块下移后,重新判断删除行是否满行
Hang++; //记录删除方块的行数
}
}
}
}
score+=100*Hang; //每删除一行,得100分
if ( Hang>0 && (score%500==0 || score/500> level-1 ) ) //得分满500速度加快升一级
{ speed-=20; level++; if(speed<200)speed+=20; }
}
2024-09-19 广告
链接中和你想要的代码是一样的,bios和graphiscs都是TC的库
#include
#include
#define
mDRAW
5
#define
mLINE
6
#define
mADOWN
7
#define
mGEN
8
#define
mLEFT
75
#define
mRIGHT
77
#define
mSPACE
57
#define
mDOWN
80
#define
mESC
1
#define
TIMEINT
2
#define
MAXX
9
#define
MAXY
30
#define
BACKCOLOR
BLACK
#define
WINX
50
#define
WINY
470
#define
GAP
6
#define
AREAX
(WINX+GAP)
#define
AREAY
(WINY-GAP)
#define
BOXW
15
int
oldarea[MAXY+1][MAXX];
int
area[MAXY+1][MAXX];
int
actW,actH,actX,actY;
int
curX,curY,curColor,curW,curH;
int
newX,newY,newColor,newW,newH;
int
active;
int
box[4][4];
int
FORCOLOR;
int
MESSAGE;
int
BOX[7][4][4]={
{
{1,1,1,1},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0}
},{
{1,1,1,0},
{1,0,0,0},
{0,0,0,0},
{0,0,0,0}
},{
{1,1,1,0},
{0,0,1,0},
{0,0,0,0},
{0,0,0,0}
},{
{1,1,1,0},
{0,1,0,0},
{0,0,0,0},
{0,0,0,0}
},{
{1,1,0,0},
{0,1,1,0},
{0,0,0,0},
{0,0,0,0}
},{
{0,1,1,0},
{1,1,0,0},
{0,0,0,0},
{0,0,0,0}
},{
{1,1,0,0},
{1,1,0,0},
{0,0,0,0},
{0,0,0,0}
}
};
void
init();
void
draw();
int
genBox();
int
getKey();
void
lineFull();
int
moveLeft();
int
moveRight();
int
moveDown();
int
rotate();
int
getW();
int
getH();
void
clearOldBox();
void
putNewBox();
int
collisionRotate(int
box[][4]);
void
getMessage();
void
dispatchMessage();
int
timeCome();
void
fallDown();
int
gameOver();
main()
{
int
i;
init();
do
{
getMessage();
dispatchMessage();
}
while(!gameOver());
getch();
closegraph();
}
void
getMessage()
{
if(MESSAGE)
return;
if(timeCome())
{
MESSAGE=mADOWN;
return;
}
if(bioskey(1))
{
MESSAGE=bioskey(0)>>8
#include <graphics.h>
#include <bios.h>
#define mDRAW 5
#define mLINE 6
#define mADOWN 7
#define mGEN 8
#define mLEFT 75
#define mRIGHT 77
#define mSPACE 57
#define mDOWN 80
#define mESC 1
#define TIMEINT 2
#define MAXX 9
#define MAXY 30
#define BACKCOLOR BLACK
#define WINX 50
#define WINY 470
#define GAP 6
#define AREAX (WINX+GAP)
#define AREAY (WINY-GAP)
#define BOXW 15
int oldarea[MAXY+1][MAXX];
int area[MAXY+1][MAXX];
int actW,actH,actX,actY;
int curX,curY,curColor,curW,curH;
int newX,newY,newColor,newW,newH;
int active;
int box[4][4];
int FORCOLOR;
int MESSAGE;
int BOX[7][4][4]={
{
{1,1,1,1},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0}
},{
{1,1,1,0},
{1,0,0,0},
{0,0,0,0},
{0,0,0,0}
},{
{1,1,1,0},
{0,0,1,0},
{0,0,0,0},
{0,0,0,0}
},{
{1,1,1,0},
{0,1,0,0},
{0,0,0,0},
{0,0,0,0}
},{
{1,1,0,0},
{0,1,1,0},
{0,0,0,0},
{0,0,0,0}
},{
{0,1,1,0},
{1,1,0,0},
{0,0,0,0},
{0,0,0,0}
},{
{1,1,0,0},
{1,1,0,0},
{0,0,0,0},
{0,0,0,0}
}
};
void init();
void draw();
int genBox();
int getKey();
void lineFull();
int moveLeft();
int moveRight();
int moveDown();
int rotate();
int getW();
int getH();
void clearOldBox();
void putNewBox();
int collisionRotate(int box[][4]);
void getMessage();
void dispatchMessage();
int timeCome();
void fallDown();
int gameOver();
main()
{
int i;
init();
do
{
getMessage();
dispatchMessage();
}
while(!gameOver());
getch();
closegraph();
}
void getMessage()
{
if(MESSAGE) return;
if(timeCome())
{
MESSAGE=mADOWN;
return;
}
if(bioskey(1))
{
MESSAGE=bioskey(0)>>8;
return;
}
}
void dispatchMessage()
{
switch(MESSAGE)
{
case mLEFT: moveLeft();break;
case mRIGHT: moveRight();break;
case mADOWN: moveDown();break;
case mSPACE: rotate();break;
case mDOWN: fallDown(); break;
case mDRAW: draw();break;
case mLINE: lineFull();break;
case mGEN: genBox();break;
case mESC: closegraph(); exit(0);
default: MESSAGE=0;
}
}
void fallDown()
{
while(active)
{
moveDown(); draw();
}
MESSAGE=mLINE;
}
int timeCome()
{
static long tm, old;
tm=biostime(0,tm);
if(tm-old<TIMEINT) return 0;
else
{
old=tm; return 1;
}
}
void init()
{
int i,j,x1,y1,x2,y2;
int driver=DETECT, mode=0;
randomize();
registerbgidriver(EGAVGA_driver);
initgraph(&driver,&mode,"");
cleardevice();
setfillstyle(SOLID_FILL,BLUE);
bar(0,0,639,479);
x1=AREAX;
y1=AREAY-BOXW*MAXY;
x2=AREAX+MAXX*BOXW;
y2=AREAY;
rectangle(--x1,--y1,++x2,++y2);
setfillstyle(SOLID_FILL,BLACK);
bar(++x1,++y1,--x2,--y2);
y1=AREAY-MAXY*BOXW; y2=AREAY;
setcolor(DARKGRAY);
for(i=0;i<MAXX;i++)
{
x1=AREAX+i*BOXW;
line(x1,y1,x1,y2);
}
x1=AREAX; x2=x1+MAXX*BOXW;
for(j=0;j<MAXY;j++)
{
y1=AREAY-j*BOXW;
line(x1,y1,x2,y1);
}
for(j=0;j<MAXY;j++)
for(i=0;i<MAXX;i++)
area[j][i]=oldarea[j][i]=0;
actX=0; actY=0; actW=MAXX-1; actH=MAXY-1;
draw();
MESSAGE=mGEN;
}
int genBox()
{
int i,j,boxidx;
boxidx=random(7); FORCOLOR=random(7)+1;
for(j=0;j<4;j++)
for(i=0;i<4;i++)
box[j][i]=BOX[boxidx][j][i];
curW=getW(); curH=getH();
curX=(MAXX+curW)/2;
if(curX+curW>=MAXX)curX=MAXX-1-curW;
curY=MAXY-1-curH;
newX=curX; newY=curY; actX=curX;actY=curY;
actW=newW=curW; actH=newH=curH;
active=1;
if(collision(box)) return 0;
putNewBox();
draw(); MESSAGE=0;
return 1;
}
void lineFull()
{
int row,col, rowEnd,full,i,j;
rowEnd=newY+newH;
if(rowEnd>=MAXY-1) rowEnd=MAXY-2;
for(row=newY; row<=rowEnd;)
{
full=1;
for(col=0;col<MAXX;col++)
if(!area[row][col]){full=0; break;}
if(!full){++row; continue;}
for(j=row; j<MAXY-1;j++)
for(i=0;i<MAXX;i++)
area[j][i]=area[j+1][i];
actX=0;actY=row; actW=MAXX-1; actH=MAXY-1-row;
draw(); rowEnd--;
}
MESSAGE=mGEN;
}
void draw()
{
int row,col,x1,y1,x2,y2;
for(row=actY;row<=actY+actH;row++)
for(col=actX;col<=actX+actW;col++)
if(area[row][col]!=oldarea[row][col])
{
if(area[row][col]==0)
setfillstyle(SOLID_FILL,BACKCOLOR);
else
setfillstyle(SOLID_FILL,FORCOLOR);
x1=AREAX+col*BOXW; x2=x1+BOXW;
y1=AREAY-(row+1)*BOXW; y2=y1+BOXW;
bar(++x1,++y1,--x2,--y2);
oldarea[row][col]=area[row][col];
}
MESSAGE=0;
}
int moveLeft()
{
newX=curX-1; clearOldBox();
if(collision(box))
{
newX=curX;
putNewBox();
MESSAGE=0;
return 0;
}
putNewBox();
actW=curW+1; actX=curX=newX;
MESSAGE=mDRAW;
return 1;
}
int moveRight()
{
newX=curX+1; clearOldBox();
if(collision(box))
{
newX=curX;
putNewBox();
MESSAGE=0;
return 0;
}
putNewBox();
actW=curW+1; actX=curX; curX=newX;
MESSAGE=mDRAW;
return 1;
}
int moveDown()
{
int i,j;
newY=curY-1;
clearOldBox();
if(collision(box))
{
newY=curY;
putNewBox();
active=0;
MESSAGE=mLINE;
return 0;
}
putNewBox();
actH=curH+1; actY=newY; curY=newY;
MESSAGE=mDRAW;
return 1;
}
int rotate()
{
int newBox[4][4];
int i,j;
clearOldBox();
for(j=0;j<4;j++)
for(i=0;i<4;i++)
newBox[j][i]=0;
for(j=0;j<4;j++)
for(i=0;i<4;i++)
newBox[curW-i][j]=box[j][i];
newW=curH; newH=curW;
if(collisionRotate(newBox))
{
newW=curW; newH=curH; newX=curX; newY=curY;
putNewBox();
MESSAGE=0;
return 0;
}
for(j=0;j<4;j++)
for(i=0;i<4;i++)
box[j][i]=newBox[j][i];
putNewBox();
actH=newH>curH? newH:curH;
actW=curX+actH-newX;
actX=newX; actY=newY; curX=newX;
curY=newY; curW=newW; curH=newH;
MESSAGE=mDRAW;
return 1;
}
int getW()
{
int i,j;
for(i=3;i>0;i--)
for(j=0;j<4;j++)
if(box[j][i]) return i;
return 0;
}
int getH()
{
int i,j;
for(j=3;j>0;j--)
for(i=0;i<4;i++)
if(box[j][i]) return j;
return 0;
}
void clearOldBox()
{
int i,j;
for(j=0;j<=curH; j++)
for(i=0;i<=curW; i++)
if(box[j][i])
area[curY+j][curX+i]=0;
}
void putNewBox()
{
int i,j;
for(j=0;j<=newH;j++)
for(i=0;i<=newW;i++)
if(box[j][i])
area[newY+j][newX+i]=FORCOLOR;
}
int collision(int cbox[][4])
{
int i,j;
if(newX<0) return 1;
if(newX+newW>=MAXX) return 1;
if(newY<0) return 1;
for(j=0;j<=newH;j++)
for(i=0;i<=newW;i++)
if(area[newY+j][newX+i]&&cbox[j][i]) return 1;
return 0;
}
int collisionRotate(int cbox[][4])
{
int i,j;
if(newX+newW>=MAXX) newX=MAXX-1-newW;
if(newY+newH>=MAXY) newY=MAXY-1-newH;
if(collision(cbox)) return 1;
for(i=0;i<=newW;i++)
for(j=0;j<=newH;j++)
if(area[newY+j][newX+i])
{
newX-=newW-i+1; goto L;
}
L: return collision(cbox);
}
int gameOver()
{
if(!active &&(curY+curH>MAXY-3)) return 1;
else return 0;
}
{
int i,j,x1,y1,x2,y2;
int driver=DETECT, mode=0;
randomize();
registerbgidriver(EGAVGA_driver); ----有问题啊!调试时候说没有定义??
initgraph(&driver,&mode,"");
我也想看懂这个!!