|
|
@ -140,6 +140,7 @@ void welcome()
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
system("cls");
|
|
|
|
system("cls");
|
|
|
|
DrawGameframe();
|
|
|
|
DrawGameframe();
|
|
|
|
|
|
|
|
Gameplay();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -192,7 +193,7 @@ void DrawGameframe()
|
|
|
|
gotoxy(FrameX+i,FrameY);
|
|
|
|
gotoxy(FrameX+i,FrameY);
|
|
|
|
printf("¨T");
|
|
|
|
printf("¨T");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for(i=2;i<Frame_width-2;i+=2){
|
|
|
|
for(i=2;i<2*Frame_width-2;i+=2){
|
|
|
|
gotoxy(FrameX+i,FrameY+Frame_height);
|
|
|
|
gotoxy(FrameX+i,FrameY+Frame_height);
|
|
|
|
printf("¨T");
|
|
|
|
printf("¨T");
|
|
|
|
a[FrameX+i][FrameY+Frame_height]=2;
|
|
|
|
a[FrameX+i][FrameY+Frame_height]=2;
|
|
|
@ -210,125 +211,195 @@ void DrawGameframe()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/********制作俄罗斯方块*********/
|
|
|
|
/**
|
|
|
|
void MakeTetris(struct Tetris *tetris){
|
|
|
|
* 制作俄罗斯方块
|
|
|
|
a[tetris->x][tetris->y]=b[0];//中心方块的图形状态
|
|
|
|
*/
|
|
|
|
switch(tetris->flag){
|
|
|
|
void MakeTetris(struct Tetris *tetris)
|
|
|
|
case 1: //田字方块
|
|
|
|
{
|
|
|
|
|
|
|
|
a[tetris->x][tetris->y]=b[0]; //中心方块位置的图形状态
|
|
|
|
|
|
|
|
switch(tetris->flag) //共7大类,19种类型
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 1: /*田字方块 ■■
|
|
|
|
|
|
|
|
■■ */
|
|
|
|
|
|
|
|
{
|
|
|
|
color(10);
|
|
|
|
color(10);
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x+2][tetris->y-1]=b[2];
|
|
|
|
a[tetris->x+2][tetris->y-1]=b[2];
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 2: //横直线方块
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2: /*直线方块 ■■■■*/
|
|
|
|
|
|
|
|
{
|
|
|
|
color(13);
|
|
|
|
color(13);
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
a[tetris->x+2][tetris->y]=b[2];
|
|
|
|
a[tetris->x+2][tetris->y]=b[2];
|
|
|
|
a[tetris->x+4][tetris->y]=b[3];
|
|
|
|
a[tetris->x+4][tetris->y]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 3: //竖直线方块
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3: /*直线方块 ■
|
|
|
|
|
|
|
|
■
|
|
|
|
|
|
|
|
■
|
|
|
|
|
|
|
|
■ */
|
|
|
|
|
|
|
|
{
|
|
|
|
color(13);
|
|
|
|
color(13);
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x][tetris->y-2]=b[2];
|
|
|
|
a[tetris->x][tetris->y+1]=b[2];
|
|
|
|
a[tetris->x][tetris->y+1]=b[3];
|
|
|
|
a[tetris->x][tetris->y+2]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 4: //T字方块
|
|
|
|
}
|
|
|
|
|
|
|
|
case 4: /*T字方块 ■■■
|
|
|
|
|
|
|
|
■ */
|
|
|
|
|
|
|
|
{
|
|
|
|
color(11);
|
|
|
|
color(11);
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
a[tetris->x+2][tetris->y]=b[2];
|
|
|
|
a[tetris->x+2][tetris->y]=b[2];
|
|
|
|
a[tetris->x][tetris->y-1]=b[3];
|
|
|
|
a[tetris->x][tetris->y+1]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 5: //顺时针90°T字方块
|
|
|
|
}
|
|
|
|
|
|
|
|
case 5: /* 顺时针90°T字方块 ■
|
|
|
|
|
|
|
|
■■
|
|
|
|
|
|
|
|
■*/
|
|
|
|
|
|
|
|
{
|
|
|
|
color(11);
|
|
|
|
color(11);
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x-2][tetris->y]=b[2];
|
|
|
|
a[tetris->x][tetris->y+1]=b[2];
|
|
|
|
a[tetris->x][tetris->y+1]=b[3];
|
|
|
|
a[tetris->x-2][tetris->y]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 6: //顺时针180°T字方块
|
|
|
|
}
|
|
|
|
|
|
|
|
case 6: /* 顺时针180°T字方块 ■
|
|
|
|
|
|
|
|
■■■*/
|
|
|
|
|
|
|
|
{
|
|
|
|
color(11);
|
|
|
|
color(11);
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x-2][tetris->y]=b[2];
|
|
|
|
a[tetris->x-2][tetris->y]=b[2];
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 7: //顺时针270°T字方块
|
|
|
|
}
|
|
|
|
|
|
|
|
case 7: /* 顺时针270°T字方块 ■
|
|
|
|
|
|
|
|
■■
|
|
|
|
|
|
|
|
■ */
|
|
|
|
|
|
|
|
{
|
|
|
|
color(11);
|
|
|
|
color(11);
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x][tetris->y+1]=b[2];
|
|
|
|
a[tetris->x][tetris->y+1]=b[2];
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 8: //Z字方块
|
|
|
|
}
|
|
|
|
|
|
|
|
case 8: /* Z字方块 ■■
|
|
|
|
|
|
|
|
■■*/
|
|
|
|
|
|
|
|
{
|
|
|
|
color(14);
|
|
|
|
color(14);
|
|
|
|
a[tetris->x+2][tetris->y+1]=b[1];
|
|
|
|
a[tetris->x][tetris->y+1]=b[1];
|
|
|
|
a[tetris->x][tetris->y+1]=b[2];
|
|
|
|
a[tetris->x-2][tetris->y]=b[2];
|
|
|
|
a[tetris->x-2][tetris->y]=b[3];
|
|
|
|
a[tetris->x+2][tetris->y+1]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 9: //顺时针Z字方块
|
|
|
|
}
|
|
|
|
|
|
|
|
case 9: /* 顺时针Z字方块 ■
|
|
|
|
|
|
|
|
■■
|
|
|
|
|
|
|
|
■ */
|
|
|
|
|
|
|
|
{
|
|
|
|
color(14);
|
|
|
|
color(14);
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x-2][tetris->y]=b[2];
|
|
|
|
a[tetris->x-2][tetris->y]=b[2];
|
|
|
|
a[tetris->x-2][tetris->y+1]=b[3];
|
|
|
|
a[tetris->x-2][tetris->y+1]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 10: //反Z字方块
|
|
|
|
}
|
|
|
|
|
|
|
|
case 10: /* 反转Z字方块 ■■
|
|
|
|
|
|
|
|
■■ */
|
|
|
|
|
|
|
|
{
|
|
|
|
color(14);
|
|
|
|
color(14);
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x-2][tetris->y-1]=b[2];
|
|
|
|
a[tetris->x-2][tetris->y-1]=b[2];
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 11: //顺时针反Z字方块
|
|
|
|
}
|
|
|
|
|
|
|
|
case 11: /* 顺时针Z字方块 ■
|
|
|
|
|
|
|
|
■■
|
|
|
|
|
|
|
|
■ */
|
|
|
|
|
|
|
|
{
|
|
|
|
color(14);
|
|
|
|
color(14);
|
|
|
|
a[tetris->x][tetris->y+1]=b[1];
|
|
|
|
a[tetris->x][tetris->y+1]=b[1];
|
|
|
|
a[tetris->x-2][tetris->y-1]=b[2];
|
|
|
|
a[tetris->x-2][tetris->y-1]=b[2];
|
|
|
|
a[tetris->x-2][tetris->y]=b[3];
|
|
|
|
a[tetris->x-2][tetris->y]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 12: //7字方块
|
|
|
|
}
|
|
|
|
|
|
|
|
case 12: /* 7字方块 ■■
|
|
|
|
|
|
|
|
■
|
|
|
|
|
|
|
|
■ */
|
|
|
|
|
|
|
|
{
|
|
|
|
color(12);
|
|
|
|
color(12);
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x][tetris->y+1]=b[2];
|
|
|
|
a[tetris->x][tetris->y+1]=b[2];
|
|
|
|
a[tetris->x-2][tetris->y-1]=b[3];
|
|
|
|
a[tetris->x-2][tetris->y-1]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 13: //顺时针90°7字方块
|
|
|
|
}
|
|
|
|
|
|
|
|
case 13: /* 顺时针90°7字方块 ■
|
|
|
|
|
|
|
|
■■■ */
|
|
|
|
|
|
|
|
{
|
|
|
|
color(12);
|
|
|
|
color(12);
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
a[tetris->x+2][tetris->y-1]=b[2];
|
|
|
|
a[tetris->x+2][tetris->y-1]=b[2];
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 14: //顺时针180°7字方块
|
|
|
|
}
|
|
|
|
|
|
|
|
case 14: /* 顺时针180°7字方块 ■
|
|
|
|
|
|
|
|
■
|
|
|
|
|
|
|
|
■■ */
|
|
|
|
|
|
|
|
{
|
|
|
|
color(12);
|
|
|
|
color(12);
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x][tetris->y+1]=b[2];
|
|
|
|
a[tetris->x][tetris->y+1]=b[2];
|
|
|
|
a[tetris->x+2][tetris->y+1]=b[3];
|
|
|
|
a[tetris->x+2][tetris->y+1]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 15: //顺时针270°7字方块
|
|
|
|
}
|
|
|
|
|
|
|
|
case 15: /* 顺时针270°7字方块 ■■■
|
|
|
|
|
|
|
|
■ */
|
|
|
|
|
|
|
|
{
|
|
|
|
color(12);
|
|
|
|
color(12);
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
a[tetris->x][tetris->y+1]=b[2];
|
|
|
|
a[tetris->x-2][tetris->y+1]=b[2];
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 16: //反7字方块
|
|
|
|
}
|
|
|
|
|
|
|
|
case 16: /* 反转7字方块 ■■
|
|
|
|
|
|
|
|
■
|
|
|
|
|
|
|
|
■ */
|
|
|
|
|
|
|
|
{
|
|
|
|
color(12);
|
|
|
|
color(12);
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x][tetris->y+1]=b[1];
|
|
|
|
a[tetris->x][tetris->y+1]=b[2];
|
|
|
|
a[tetris->x][tetris->y-1]=b[2];
|
|
|
|
a[tetris->x+2][tetris->y-1]=b[3];
|
|
|
|
a[tetris->x+2][tetris->y-1]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 17: //顺时针90°反7字方块
|
|
|
|
}
|
|
|
|
|
|
|
|
case 17: /* 顺时针转90°7字方块 ■■■
|
|
|
|
|
|
|
|
■*/
|
|
|
|
|
|
|
|
{
|
|
|
|
color(12);
|
|
|
|
color(12);
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
a[tetris->x+2][tetris->y+1]=b[2];
|
|
|
|
a[tetris->x+2][tetris->y+1]=b[2];
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 18: //顺时针180°反7字方块
|
|
|
|
}
|
|
|
|
|
|
|
|
case 18: /* 顺时针转180°7字方块 ■
|
|
|
|
|
|
|
|
■
|
|
|
|
|
|
|
|
■■ */
|
|
|
|
|
|
|
|
{
|
|
|
|
color(12);
|
|
|
|
color(12);
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x][tetris->y-1]=b[1];
|
|
|
|
a[tetris->x][tetris->y+1]=b[2];
|
|
|
|
a[tetris->x][tetris->y+1]=b[2];
|
|
|
|
a[tetris->x-2][tetris->y+1]=b[3];
|
|
|
|
a[tetris->x-2][tetris->y+1]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 19: //顺时针270°反7字方块
|
|
|
|
}
|
|
|
|
|
|
|
|
case 19: /* 顺指针转270°7字方块 ■
|
|
|
|
|
|
|
|
■■■*/
|
|
|
|
|
|
|
|
{
|
|
|
|
color(12);
|
|
|
|
color(12);
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
a[tetris->x-2][tetris->y]=b[1];
|
|
|
|
a[tetris->x-2][tetris->y-1]=b[2];
|
|
|
|
a[tetris->x-2][tetris->y-1]=b[2];
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
a[tetris->x+2][tetris->y]=b[3];
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -364,52 +435,59 @@ void PrintTetris(struct Tetris *tetris){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******判断方块能否移动******/
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 判断是否可移动
|
|
|
|
|
|
|
|
*/
|
|
|
|
int ifMove(struct Tetris *tetris)
|
|
|
|
int ifMove(struct Tetris *tetris)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(a[tetris->x][tetris->y]!=0){
|
|
|
|
if(a[tetris->x][tetris->y]!=0)//当中心方块位置上有图案时,返回值为0,即不可移动
|
|
|
|
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
if(
|
|
|
|
if(
|
|
|
|
(tetris->flag==1&&(a[tetris->x][tetris->y-1]==0&&
|
|
|
|
( tetris->flag==1 && ( a[tetris->x][tetris->y-1]==0 &&/*当为田字方块且除中心方块位
|
|
|
|
a[tetris->x][tetris->y-1]==0&&a[tetris->x+2][tetris->y]==0))||
|
|
|
|
置外,其他"■"字方块位置上无图案时,说明这个位置能够放下田字方块,可以移动到这个位置,返回值为1,即
|
|
|
|
(tetris->flag==2&&(a[tetris->x-2][tetris->y]==0&&
|
|
|
|
可移动*/
|
|
|
|
a[tetris->x+2][tetris->y]==0&&a[tetris->x+4][tetris->y]==0))||
|
|
|
|
a[tetris->x+2][tetris->y-1]==0 && a[tetris->x+2][tetris->y]==0 ) ) ||
|
|
|
|
(tetris->flag==3&&(a[tetris->x][tetris->y-1]==0&&
|
|
|
|
//或为直线方块且除中心方块位置外,其他"■"字方块位置上无图案时,返回值为1,即可移动
|
|
|
|
a[tetris->x][tetris->y-2]==0&&a[tetris->x][tetris->y+1]==0))||
|
|
|
|
( tetris->flag==2 && ( a[tetris->x-2][tetris->y]==0 &&
|
|
|
|
(tetris->flag==4&&(a[tetris->x-2][tetris->y]==0&&
|
|
|
|
a[tetris->x+2][tetris->y]==0 && a[tetris->x+4][tetris->y]==0 ) ) ||
|
|
|
|
a[tetris->x+2][tetris->y]==0&&a[tetris->x][tetris->y+1]==0))||
|
|
|
|
( tetris->flag==3 && ( a[tetris->x][tetris->y-1]==0 && //直线方块(竖)
|
|
|
|
(tetris->flag==5&&(a[tetris->x][tetris->y-1]==0&&
|
|
|
|
a[tetris->x][tetris->y-2]==0 && a[tetris->x][tetris->y+1]==0 ) ) ||
|
|
|
|
a[tetris->x][tetris->y+1]==0&&a[tetris->x-2][tetris->y]==0))||
|
|
|
|
( tetris->flag==4 && ( a[tetris->x-2][tetris->y]==0 && //T字方块
|
|
|
|
(tetris->flag==6&&(a[tetris->x][tetris->y-1]==0&&
|
|
|
|
a[tetris->x+2][tetris->y]==0 && a[tetris->x][tetris->y+1]==0 ) ) ||
|
|
|
|
a[tetris->x-2][tetris->y]==0&&a[tetris->x+2][tetris->y]==0))||
|
|
|
|
( tetris->flag==5 && ( a[tetris->x][tetris->y-1]==0 && //T字方块(顺时针90°)
|
|
|
|
(tetris->flag==7&&(a[tetris->x][tetris->y-1]==0&&
|
|
|
|
a[tetris->x][tetris->y+1]==0 && a[tetris->x-2][tetris->y]==0 ) ) ||
|
|
|
|
a[tetris->x][tetris->y+1]==0&&a[tetris->x+2][tetris->y]==0))||
|
|
|
|
( tetris->flag==6 && ( a[tetris->x][tetris->y-1]==0 && //T字方块(顺时针180°)
|
|
|
|
(tetris->flag==8&&(a[tetris->x][tetris->y+1]==0&&
|
|
|
|
a[tetris->x-2][tetris->y]==0 && a[tetris->x+2][tetris->y]==0 ) ) ||
|
|
|
|
a[tetris->x-2][tetris->y]==0&&a[tetris->x+2][tetris->y+1]==0))||
|
|
|
|
( tetris->flag==7 && ( a[tetris->x][tetris->y-1]==0 && //T字方块(顺时针270°)
|
|
|
|
(tetris->flag==9&&(a[tetris->x][tetris->y-1]==0&&
|
|
|
|
a[tetris->x][tetris->y+1]==0 && a[tetris->x+2][tetris->y]==0 ) ) ||
|
|
|
|
a[tetris->x-2][tetris->y]==0&&a[tetris->x-2][tetris->y+1]==0))||
|
|
|
|
( tetris->flag==8 && ( a[tetris->x][tetris->y+1]==0 && //Z字方块
|
|
|
|
(tetris->flag==10&&(a[tetris->x][tetris->y-1]==0&&
|
|
|
|
a[tetris->x-2][tetris->y]==0 && a[tetris->x+2][tetris->y+1]==0 ) ) ||
|
|
|
|
a[tetris->x-2][tetris->y-1]==0&&a[tetris->x+2][tetris->y]==0))||
|
|
|
|
( tetris->flag==9 && ( a[tetris->x][tetris->y-1]==0 && //Z字方块(顺时针180°)
|
|
|
|
(tetris->flag==11&&(a[tetris->x][tetris->y+1]==0&&
|
|
|
|
a[tetris->x-2][tetris->y]==0 && a[tetris->x-2][tetris->y+1]==0 ) ) ||
|
|
|
|
a[tetris->x-2][tetris->y-1]==0&&a[tetris->x-2][tetris->y]==0))||
|
|
|
|
( tetris->flag==10 && ( a[tetris->x][tetris->y-1]==0 && //Z字方块(反转)
|
|
|
|
(tetris->flag==12&&(a[tetris->x][tetris->y-1]==0&&
|
|
|
|
a[tetris->x-2][tetris->y-1]==0 && a[tetris->x+2][tetris->y]==0 ) ) ||
|
|
|
|
a[tetris->x][tetris->y+1]==0&&a[tetris->x-2][tetris->y-1]==0))||
|
|
|
|
( tetris->flag==11 && ( a[tetris->x][tetris->y+1]==0 &&//Z字方块(反转+顺时针180°)
|
|
|
|
(tetris->flag==13&&(a[tetris->x-2][tetris->y]==0&&
|
|
|
|
a[tetris->x-2][tetris->y-1]==0 && a[tetris->x-2][tetris->y]==0 ) ) ||
|
|
|
|
a[tetris->x+2][tetris->y-1]==0&&a[tetris->x+2][tetris->y]==0))||
|
|
|
|
( tetris->flag==12 && ( a[tetris->x][tetris->y-1]==0 && //7字方块
|
|
|
|
(tetris->flag==14&&(a[tetris->x][tetris->y-1]==0&&
|
|
|
|
a[tetris->x][tetris->y+1]==0 && a[tetris->x-2][tetris->y-1]==0 ) ) ||
|
|
|
|
a[tetris->x][tetris->y+1]==0&&a[tetris->x+2][tetris->y+1]==0))||
|
|
|
|
( tetris->flag==15 && ( a[tetris->x-2][tetris->y]==0 && //7字方块(顺时针90°)
|
|
|
|
(tetris->flag==15&&(a[tetris->x-2][tetris->y]==0&&
|
|
|
|
a[tetris->x-2][tetris->y+1]==0 && a[tetris->x+2][tetris->y]==0 ) ) ||
|
|
|
|
a[tetris->x-2][tetris->y+1]==0&&a[tetris->x+2][tetris->y]==0))||
|
|
|
|
( tetris->flag==14 && ( a[tetris->x][tetris->y-1]==0 && //7字方块(顺时针180°)
|
|
|
|
(tetris->flag==16&&(a[tetris->x][tetris->y+1]==0&&
|
|
|
|
a[tetris->x][tetris->y+1]==0 && a[tetris->x+2][tetris->y+1]==0 ) ) ||
|
|
|
|
a[tetris->x][tetris->y-1]==0&&a[tetris->x+2][tetris->y-1]==0))||
|
|
|
|
( tetris->flag==13 && ( a[tetris->x-2][tetris->y]==0 && //7字方块(顺时针270°)
|
|
|
|
(tetris->flag==17&&(a[tetris->x-2][tetris->y]==0&&
|
|
|
|
a[tetris->x+2][tetris->y-1]==0 && a[tetris->x+2][tetris->y]==0 ) ) ||
|
|
|
|
a[tetris->x+2][tetris->y+1]==0&&a[tetris->x+2][tetris->y]==0))||
|
|
|
|
( tetris->flag==16 && ( a[tetris->x][tetris->y+1]==0 && //7字方块(反转)
|
|
|
|
(tetris->flag==18&&(a[tetris->x][tetris->y-1]==0&&
|
|
|
|
a[tetris->x][tetris->y-1]==0 && a[tetris->x+2][tetris->y-1]==0 ) ) ||
|
|
|
|
a[tetris->x][tetris->y+1]==0&&a[tetris->x-2][tetris->y+1]==0))||
|
|
|
|
( tetris->flag==19 && ( a[tetris->x-2][tetris->y]==0 &&//7字方块(反转+顺时针90°)
|
|
|
|
(tetris->flag==19&&(a[tetris->x-2][tetris->y]==0&&
|
|
|
|
a[tetris->x-2][tetris->y-1]==0 && a[tetris->x+2][tetris->y]==0 ) ) ||
|
|
|
|
a[tetris->x-2][tetris->y-1]==0&&a[tetris->x+2][tetris->y]==0)))
|
|
|
|
( tetris->flag==18 && ( a[tetris->x][tetris->y-1]==0 &&//7字方块(反转+顺时针180°)
|
|
|
|
|
|
|
|
a[tetris->x][tetris->y+1]==0 && a[tetris->x-2][tetris->y+1]==0 ) ) ||
|
|
|
|
|
|
|
|
( tetris->flag==17 && ( a[tetris->x-2][tetris->y]==0 &&//7字方块(反转+顺时针270°)
|
|
|
|
|
|
|
|
a[tetris->x+2][tetris->y+1]==0 && a[tetris->x+2][tetris->y]==0 ) ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -418,40 +496,60 @@ int ifMove(struct Tetris *tetris)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******清除俄罗斯方块的痕迹********/
|
|
|
|
|
|
|
|
void CleanTetris(struct Tetris *tetris){
|
|
|
|
void CleanTetris(struct Tetris *tetris)
|
|
|
|
for(i=0;i<4;i++){
|
|
|
|
{
|
|
|
|
b[i]=0;
|
|
|
|
for(i=0;i<4;i++) //数组b[4]中有4个元素,循环这4个元素,让每个元素的值都为0
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
b[i]=0; //数组b[4]的每个元素的值都为0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MakeTetris(tetris);
|
|
|
|
MakeTetris(tetris); //制作俄罗斯方块
|
|
|
|
for(i=tetris->x-2;i<=tetris->x+4;i+=2){
|
|
|
|
for( i = tetris->x - 2;i <= tetris->x + 4; i+=2 ) //■X■■ X为中心方块
|
|
|
|
for(tetris->y-2;i<=tetris->y+1;j++){
|
|
|
|
{
|
|
|
|
if(a[i][j]==0&&j>FrameY){
|
|
|
|
for(j = tetris->y-2;j <= tetris->y + 1;j++) /* ■
|
|
|
|
|
|
|
|
■
|
|
|
|
|
|
|
|
X
|
|
|
|
|
|
|
|
■ */
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if( a[i][j] == 0 && j > FrameY ) //如果这个位置上没有图案,并且处于游戏界面当中
|
|
|
|
|
|
|
|
{
|
|
|
|
gotoxy(i,j);
|
|
|
|
gotoxy(i,j);
|
|
|
|
printf(" ");
|
|
|
|
printf(" "); //清除方块
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******判断是否满行********/
|
|
|
|
/**
|
|
|
|
void Del_Fullline(struct Tetris *tetris){
|
|
|
|
* 判断是否满行并删除满行的俄罗斯方块
|
|
|
|
int k,del_rows=0;
|
|
|
|
*/
|
|
|
|
for(j=FrameY+Frame_height-1;j>=FrameY+1;j--){
|
|
|
|
void Del_Fullline(struct Tetris *tetris) //当某行有Frame_width-2个方块时,则满行消除
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int k,del_rows=0; //分别用于记录某行方块的个数和删除方块的行数的变量
|
|
|
|
|
|
|
|
for(j=FrameY+Frame_height-1;j>=FrameY+1;j--)
|
|
|
|
|
|
|
|
{
|
|
|
|
k=0;
|
|
|
|
k=0;
|
|
|
|
for(i=FrameX+2;i<FrameX+2*Frame_width-2;i+=2){
|
|
|
|
for(i=FrameX+2;i<FrameX+2*Frame_width-2;i+=2)
|
|
|
|
if(a[i][j]==1){
|
|
|
|
{
|
|
|
|
k++;
|
|
|
|
if(a[i][j]==1) //纵坐标依次从下往上,横坐标依次由左至右判断是否满行
|
|
|
|
if(k==Frame_width-2){
|
|
|
|
{
|
|
|
|
for(k=FrameX+2;k<FrameX+2*Frame_width-2;k+=2){
|
|
|
|
k++; //记录此行方块的个数
|
|
|
|
|
|
|
|
if(k==Frame_width-2) //如果满行
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for(k=FrameX+2;k<FrameX+2*Frame_width-2;k+=2) //删除满行的方块
|
|
|
|
|
|
|
|
{
|
|
|
|
a[k][j]=0;
|
|
|
|
a[k][j]=0;
|
|
|
|
gotoxy(k,j);
|
|
|
|
gotoxy(k,j);
|
|
|
|
printf("");
|
|
|
|
printf(" ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for(k=j-1;k>FrameY;k--){
|
|
|
|
//如果删除行以上的位置有方块,则先清除,再将方块下移一个位置
|
|
|
|
for(i=FrameX+2;i<FrameX+2*Frame_width-2;i+=2){
|
|
|
|
for(k=j-1;k>FrameY;k--)
|
|
|
|
if(a[i][k]==1){
|
|
|
|
{
|
|
|
|
|
|
|
|
for(i=FrameX+2;i<FrameX+2*Frame_width-2;i+=2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(a[i][k]==1)
|
|
|
|
|
|
|
|
{
|
|
|
|
a[i][k]=0;
|
|
|
|
a[i][k]=0;
|
|
|
|
gotoxy(i,k);
|
|
|
|
gotoxy(i,k);
|
|
|
|
printf(" ");
|
|
|
|
printf(" ");
|
|
|
@ -461,15 +559,16 @@ void Del_Fullline(struct Tetris *tetris){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
j++;
|
|
|
|
j++; //方块下移后,重新判断删除行是否满行
|
|
|
|
del_rows++;
|
|
|
|
del_rows++; //记录删除方块的行数
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tetris->score+=100*del_rows;
|
|
|
|
tetris->score+=100*del_rows; //每删除一行,得100分
|
|
|
|
if(del_rows>0&&(tetris->score%1000==0||tetris->score/1000>tetris->level-1)){
|
|
|
|
if( del_rows>0 && ( tetris->score%1000==0 || tetris->score/1000>tetris->level-1 ) )
|
|
|
|
tetris->speed-+20;
|
|
|
|
{ //如果得1000分即累计删除10行,速度加快20ms并升一级
|
|
|
|
|
|
|
|
tetris->speed-=20;
|
|
|
|
tetris->level++;
|
|
|
|
tetris->level++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -486,130 +585,160 @@ void Flag(struct Tetris *tetris){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******开始游戏*******/
|
|
|
|
/**
|
|
|
|
void Gameplay(){
|
|
|
|
* 开始游戏
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void Gameplay()
|
|
|
|
|
|
|
|
{
|
|
|
|
int n;
|
|
|
|
int n;
|
|
|
|
struct Tetris t,*tetris=&t;
|
|
|
|
struct Tetris t,*tetris=&t; //定义结构体的指针并指向结构体变量
|
|
|
|
char ch;
|
|
|
|
char ch; //定义接收键盘输入的变量
|
|
|
|
tetris->number=0;
|
|
|
|
tetris->number=0; //初始化俄罗斯方块数为0个
|
|
|
|
tetris->speed=300;
|
|
|
|
tetris->speed=300; //初始移动速度为300ms
|
|
|
|
tetris->score=0;
|
|
|
|
tetris->score=0; //初始游戏的分数为0分
|
|
|
|
tetris->level=1;
|
|
|
|
tetris->level=1; //初始游戏为第1关
|
|
|
|
while(1){
|
|
|
|
while(1) //循环产生方块,直至游戏结束
|
|
|
|
Flag(tetris);
|
|
|
|
{
|
|
|
|
Temp=tetris->flag;
|
|
|
|
Flag(tetris); //得到产生俄罗斯方块类型的序号
|
|
|
|
tetris->x=FrameX+2*Frame_width+6;
|
|
|
|
Temp=tetris->flag; //记住当前俄罗斯方块序号
|
|
|
|
tetris->y=FrameY+10;
|
|
|
|
tetris->x=FrameX+2*Frame_width+6; //获得预览界面方块的x坐标
|
|
|
|
tetris->flag=tetris->next;
|
|
|
|
tetris->y=FrameY+10; //获得预览界面方块的y坐标
|
|
|
|
PrintTetris(tetris);
|
|
|
|
tetris->flag = tetris->next; //获得下一个俄罗斯方块的序号
|
|
|
|
tetris->x=FrameX+Frame_width;
|
|
|
|
PrintTetris(tetris); //调用打印俄罗斯方块方法
|
|
|
|
tetris->y=FrameY-1;
|
|
|
|
tetris->x=FrameX+Frame_width; //获得游戏窗口中心方块x坐标
|
|
|
|
tetris->flag=Temp;
|
|
|
|
tetris->y=FrameY-1; //获得游戏窗口中心方块y坐标
|
|
|
|
/******获取键盘按键*******/
|
|
|
|
tetris->flag=Temp; //按键操作
|
|
|
|
while(1){
|
|
|
|
while(1) //控制方块方向,直至方块不再下移
|
|
|
|
label:PrintTetris(tetris);
|
|
|
|
{
|
|
|
|
Sleep(tetris->speed);//控制时间
|
|
|
|
label:PrintTetris(tetris); //打印俄罗斯方块
|
|
|
|
CleanTetris(tetris);
|
|
|
|
Sleep(tetris->speed); //延缓时间
|
|
|
|
Temp1=tetris->x;
|
|
|
|
CleanTetris(tetris); //清除痕迹
|
|
|
|
Temp2+tetris->flag;
|
|
|
|
Temp1=tetris->x; //记住中心方块横坐标的值
|
|
|
|
if(kbhit()){
|
|
|
|
Temp2=tetris->flag; //记住当前俄罗斯方块序号
|
|
|
|
|
|
|
|
if(kbhit()) //判断是否有键盘输入,有则用ch↓接收
|
|
|
|
|
|
|
|
{
|
|
|
|
ch=getch();
|
|
|
|
ch=getch();
|
|
|
|
if(ch==75){
|
|
|
|
if(ch==75) //按 ←键则向左动,中心横坐标减2
|
|
|
|
tetris->x-=2; //←键左移
|
|
|
|
{
|
|
|
|
|
|
|
|
tetris->x-=2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ch==77) //按 →键则向右动,中心横坐标加2
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
tetris->x+=2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ch==80) //按 ↓键则加速下落
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(ifMove(tetris)!=0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
tetris->y+=2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ifMove(tetris)==0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
tetris->y=FrameY+Frame_height-2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(ch==77) tetris->x+=2;//→键右移
|
|
|
|
|
|
|
|
if(ch==80){ //↓键加速下落
|
|
|
|
|
|
|
|
if(ifMove(tetris)!=0) tetris->y+=2;
|
|
|
|
|
|
|
|
else tetris->y=FrameY+Frame_height-2;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(ch==72){
|
|
|
|
if(ch==72) //按 ↑键则变体,即当前方块顺时针转90度
|
|
|
|
if(tetris->flag>=2&&tetris->flag<=3){
|
|
|
|
{
|
|
|
|
|
|
|
|
if( tetris->flag>=2 && tetris->flag<=3 ) //如果是直线方块
|
|
|
|
|
|
|
|
{
|
|
|
|
tetris->flag++;
|
|
|
|
tetris->flag++;
|
|
|
|
tetris->flag%=2;
|
|
|
|
tetris->flag%=2;
|
|
|
|
tetris->flag+=2;
|
|
|
|
tetris->flag+=2;
|
|
|
|
}//直线方块
|
|
|
|
}
|
|
|
|
if(tetris->flag>=4&&tetris->flag<=7){
|
|
|
|
if( tetris->flag>=4 && tetris->flag<=7 ) //如果是T字方块
|
|
|
|
|
|
|
|
{
|
|
|
|
tetris->flag++;
|
|
|
|
tetris->flag++;
|
|
|
|
tetris->flag%=4;
|
|
|
|
tetris->flag%=4;
|
|
|
|
tetris->flag+=4;
|
|
|
|
tetris->flag+=4;
|
|
|
|
}//T字方块
|
|
|
|
}
|
|
|
|
if(tetris->flag>=8&&tetris->flag<=11){
|
|
|
|
if( tetris->flag>=8 && tetris->flag<=11 ) //如果是Z字方块
|
|
|
|
|
|
|
|
{
|
|
|
|
tetris->flag++;
|
|
|
|
tetris->flag++;
|
|
|
|
tetris->flag%=4;
|
|
|
|
tetris->flag%=4;
|
|
|
|
tetris->flag+=8;
|
|
|
|
tetris->flag+=8;
|
|
|
|
}//Z字方块
|
|
|
|
}
|
|
|
|
if(tetris->flag>=12&&tetris->flag<=15){
|
|
|
|
if( tetris->flag>=12 && tetris->flag<=15 ) //如果是7字方块
|
|
|
|
|
|
|
|
{
|
|
|
|
tetris->flag++;
|
|
|
|
tetris->flag++;
|
|
|
|
tetris->flag%=4;
|
|
|
|
tetris->flag%=4;
|
|
|
|
tetris->flag+=12;
|
|
|
|
tetris->flag+=12;
|
|
|
|
}// 7字方块
|
|
|
|
}
|
|
|
|
if(tetris->flag>=16&&tetris->flag<=19){
|
|
|
|
if( tetris->flag>=16 && tetris->flag<=19 ) //如果是反7字方块
|
|
|
|
|
|
|
|
{
|
|
|
|
tetris->flag++;
|
|
|
|
tetris->flag++;
|
|
|
|
tetris->flag%=4;
|
|
|
|
tetris->flag%=4;
|
|
|
|
tetris->flag+=16;
|
|
|
|
tetris->flag+=16;
|
|
|
|
}//反7字方块
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(ch==32) //空格暂停
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ch == 32) //按空格键,暂停
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PrintTetris(tetris);
|
|
|
|
PrintTetris(tetris);
|
|
|
|
while(1){
|
|
|
|
while(1)
|
|
|
|
if(kbhit()){
|
|
|
|
{
|
|
|
|
|
|
|
|
if(kbhit()) //再按空格键,继续游戏
|
|
|
|
|
|
|
|
{
|
|
|
|
ch=getch();
|
|
|
|
ch=getch();
|
|
|
|
if(ch==32) goto label;
|
|
|
|
if(ch == 32)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
goto label;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(ch==27){ //ESC退出游戏
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ch == 27)
|
|
|
|
|
|
|
|
{
|
|
|
|
system("cls");
|
|
|
|
system("cls");
|
|
|
|
memset(a,0,6400*sizeof(int));//初始化数组
|
|
|
|
memset(a,0,6400*sizeof(int));
|
|
|
|
|
|
|
|
title(); //初始化a数组
|
|
|
|
welcome();
|
|
|
|
welcome();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(ifMove(tetris)==0){
|
|
|
|
if(ifMove(tetris)==0) //如果不可动,上面操作无效
|
|
|
|
|
|
|
|
{
|
|
|
|
tetris->x=Temp1;
|
|
|
|
tetris->x=Temp1;
|
|
|
|
tetris->flag=Temp2;
|
|
|
|
tetris->flag=Temp2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else //如果可动,执行操作
|
|
|
|
|
|
|
|
{
|
|
|
|
goto label;
|
|
|
|
goto label;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tetris->y++;
|
|
|
|
tetris->y++; //如果没有操作指令,方块向下移动
|
|
|
|
if(ifMove(tetris)==0){
|
|
|
|
if(ifMove(tetris)==0) //如果向下移动且不可动,方块放在此处
|
|
|
|
|
|
|
|
{
|
|
|
|
tetris->y--;
|
|
|
|
tetris->y--;
|
|
|
|
PrintTetris(tetris);
|
|
|
|
PrintTetris(tetris);
|
|
|
|
Del_Fullline(tetris);
|
|
|
|
Del_Fullline(tetris);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}//游戏结束条件:方块触到框顶位置
|
|
|
|
//游戏结束
|
|
|
|
for(i=tetris->y-2;i<tetris->y+2;i++)
|
|
|
|
for(i=tetris->y-2;i<tetris->y+2;i++){
|
|
|
|
{
|
|
|
|
if(i==FrameY){
|
|
|
|
if(i==FrameY)
|
|
|
|
system("cls");
|
|
|
|
{
|
|
|
|
gotoxy(29,7);
|
|
|
|
system("cls"); //清屏
|
|
|
|
|
|
|
|
gotoxy(29,7); //设置显示位置
|
|
|
|
printf(" \n");
|
|
|
|
printf(" \n");
|
|
|
|
color(12);
|
|
|
|
color(12); //红色
|
|
|
|
printf("\t\t\t████ █ █ ██ \n");
|
|
|
|
printf("\t\t\t■■■■ ■ ■ ■■ \n");
|
|
|
|
|
|
|
|
printf("\t\t\t■ ■■ ■ ■ ■ \n");
|
|
|
|
printf("\t\t\t█ ██ █ █ █ \n");
|
|
|
|
printf("\t\t\t■■■ ■ ■ ■ ■ ■ \n");
|
|
|
|
|
|
|
|
printf("\t\t\t■ ■ ■ ■ ■ ■ \n");
|
|
|
|
printf("\t\t\t███ █ █ █ █ █ \n");
|
|
|
|
printf("\t\t\t■■■■ ■ ■ ■■ \n");
|
|
|
|
|
|
|
|
|
|
|
|
printf("\t\t\t█ █ ██ █ █ \n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\t\t\t████ █ █ ██ \n");
|
|
|
|
|
|
|
|
gotoxy(17,18);
|
|
|
|
gotoxy(17,18);
|
|
|
|
color(14);
|
|
|
|
color(14);
|
|
|
|
printf("我要重新玩一局---------1");
|
|
|
|
printf("我要重新玩一局-------1");
|
|
|
|
gotoxy(44,18);
|
|
|
|
gotoxy(44,18);
|
|
|
|
printf("不玩了,退出-----------2\n");
|
|
|
|
printf("不玩了,退出吧-------2\n");
|
|
|
|
int n;
|
|
|
|
int n;
|
|
|
|
gotoxy(32,20);
|
|
|
|
gotoxy(32,20);
|
|
|
|
printf("选择【1/2】");
|
|
|
|
printf("选择【1/2】:");
|
|
|
|
color(11);
|
|
|
|
color(11);
|
|
|
|
scanf("%d",&n);
|
|
|
|
scanf("%d", &n); //输入1或2
|
|
|
|
switch(n){
|
|
|
|
switch (n) //分支语句
|
|
|
|
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
system("cls");
|
|
|
|
system("cls");
|
|
|
|
Replay(tetris);
|
|
|
|
Replay(tetris); //重新开始游戏
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
exit(0);
|
|
|
|
exit(0);
|
|
|
@ -617,7 +746,7 @@ void Gameplay(){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tetris->flag=tetris->next;
|
|
|
|
tetris->flag = tetris->next; //清除下一个俄罗斯方块的图形(右边窗口)
|
|
|
|
tetris->x=FrameX+2*Frame_width+6;
|
|
|
|
tetris->x=FrameX+2*Frame_width+6;
|
|
|
|
tetris->y=FrameY+10;
|
|
|
|
tetris->y=FrameY+10;
|
|
|
|
CleanTetris(tetris);
|
|
|
|
CleanTetris(tetris);
|
|
|
@ -625,6 +754,15 @@ void Gameplay(){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******重新开始游戏函数*******/
|
|
|
|
|
|
|
|
void Replay(struct Tetris *tetris){
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
memset(a,0,6400*sizeof(int));
|
|
|
|
|
|
|
|
DrawGameframe();
|
|
|
|
|
|
|
|
Gameplay();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******Ö÷şŻĘý*******/
|
|
|
|
/*******Ö÷şŻĘý*******/
|
|
|
|
int main(){
|
|
|
|
int main(){
|
|
|
|
title();
|
|
|
|
title();
|
|
|
|