diff --git a/俄罗斯方块.c b/俄罗斯方块.c index 519ae73..6342cb7 100644 --- a/俄罗斯方块.c +++ b/俄罗斯方块.c @@ -140,6 +140,7 @@ void welcome() case 1: system("cls"); DrawGameframe(); + Gameplay(); break; case 2: break; @@ -192,7 +193,7 @@ void DrawGameframe() gotoxy(FrameX+i,FrameY); printf("T"); } - for(i=2;ix][tetris->y]=b[0];//ķͼ״̬ - switch(tetris->flag){ - case 1: //ַ +/** + * ˹ + */ +void MakeTetris(struct Tetris *tetris) +{ + a[tetris->x][tetris->y]=b[0]; //ķλõͼ״̬ + switch(tetris->flag) //7࣬19 + { + case 1: /*ַ + */ + { color(10); - a[tetris->x][tetris->y-1]=b[1]; - a[tetris->x+2][tetris->y-1]=b[2]; - a[tetris->x+2][tetris->y]=b[3]; - break; - case 2: //ֱ߷ - color(13); - a[tetris->x-2][tetris->y]=b[1]; - a[tetris->x+2][tetris->y]=b[2]; - a[tetris->x+4][tetris->y]=b[3]; - break; - case 3: //ֱ߷ - color(13); - a[tetris->x][tetris->y-1]=b[1]; - a[tetris->x][tetris->y-2]=b[2]; - a[tetris->x][tetris->y+1]=b[3]; - break; - case 4: //Tַ - color(11); - a[tetris->x-2][tetris->y]=b[1]; - a[tetris->x+2][tetris->y]=b[2]; - a[tetris->x][tetris->y-1]=b[3]; - break; - case 5: //˳ʱ90Tַ - color(11); - a[tetris->x][tetris->y-1]=b[1]; - a[tetris->x-2][tetris->y]=b[2]; - a[tetris->x][tetris->y+1]=b[3]; - break; - case 6: //˳ʱ180Tַ - color(11); - a[tetris->x][tetris->y-1]=b[1]; - a[tetris->x-2][tetris->y]=b[2]; - a[tetris->x+2][tetris->y]=b[3]; - break; - case 7: //˳ʱ270Tַ - color(11); - a[tetris->x][tetris->y-1]=b[1]; - a[tetris->x][tetris->y+1]=b[2]; - a[tetris->x+2][tetris->y]=b[3]; - break; - case 8: //Zַ - color(14); - a[tetris->x+2][tetris->y+1]=b[1]; - a[tetris->x][tetris->y+1]=b[2]; - a[tetris->x-2][tetris->y]=b[3]; - break; - case 9: //˳ʱZַ - color(14); - a[tetris->x][tetris->y-1]=b[1]; - a[tetris->x-2][tetris->y]=b[2]; - a[tetris->x-2][tetris->y+1]=b[3]; - break; - case 10: //Zַ - color(14); - a[tetris->x][tetris->y-1]=b[1]; - a[tetris->x-2][tetris->y-1]=b[2]; - a[tetris->x+2][tetris->y]=b[3]; - break; - case 11: //˳ʱ뷴Zַ - color(14); - a[tetris->x][tetris->y+1]=b[1]; - a[tetris->x-2][tetris->y-1]=b[2]; - a[tetris->x-2][tetris->y]=b[3]; - break; - case 12: //7ַ - color(12); - a[tetris->x][tetris->y-1]=b[1]; - a[tetris->x][tetris->y+1]=b[2]; - a[tetris->x-2][tetris->y-1]=b[3]; - break; - case 13: //˳ʱ907ַ - color(12); - a[tetris->x-2][tetris->y]=b[1]; - a[tetris->x+2][tetris->y-1]=b[2]; - a[tetris->x+2][tetris->y]=b[3]; - break; - case 14: //˳ʱ1807ַ - color(12); - a[tetris->x][tetris->y-1]=b[1]; - a[tetris->x][tetris->y+1]=b[2]; - a[tetris->x+2][tetris->y+1]=b[3]; - break; - case 15: //˳ʱ2707ַ - color(12); - a[tetris->x][tetris->y-1]=b[1]; - a[tetris->x][tetris->y+1]=b[2]; - a[tetris->x+2][tetris->y]=b[3]; - break; - case 16: //7ַ - color(12); - a[tetris->x][tetris->y-1]=b[1]; - a[tetris->x][tetris->y+1]=b[2]; - a[tetris->x+2][tetris->y-1]=b[3]; - break; - case 17: //˳ʱ90㷴7ַ - color(12); - a[tetris->x-2][tetris->y]=b[1]; - a[tetris->x+2][tetris->y+1]=b[2]; - a[tetris->x+2][tetris->y]=b[3]; - break; - case 18: //˳ʱ180㷴7ַ - color(12); - a[tetris->x][tetris->y-1]=b[1]; - a[tetris->x][tetris->y+1]=b[2]; - a[tetris->x-2][tetris->y+1]=b[3]; - break; - case 19: //˳ʱ270㷴7ַ - color(12); - a[tetris->x-2][tetris->y]=b[1]; - a[tetris->x-2][tetris->y-1]=b[2]; - a[tetris->x+2][tetris->y]=b[3]; - break; - } + a[tetris->x][tetris->y-1]=b[1]; + a[tetris->x+2][tetris->y-1]=b[2]; + a[tetris->x+2][tetris->y]=b[3]; + break; + } + case 2: /*ֱ߷ */ + { + color(13); + a[tetris->x-2][tetris->y]=b[1]; + a[tetris->x+2][tetris->y]=b[2]; + a[tetris->x+4][tetris->y]=b[3]; + break; + } + case 3: /*ֱ߷ + + + */ + { + color(13); + a[tetris->x][tetris->y-1]=b[1]; + a[tetris->x][tetris->y+1]=b[2]; + a[tetris->x][tetris->y+2]=b[3]; + break; + } + case 4: /*Tַ + */ + { + color(11); + a[tetris->x-2][tetris->y]=b[1]; + a[tetris->x+2][tetris->y]=b[2]; + a[tetris->x][tetris->y+1]=b[3]; + break; + } + case 5: /* ˳ʱ90Tַ + + */ + { + color(11); + a[tetris->x][tetris->y-1]=b[1]; + a[tetris->x][tetris->y+1]=b[2]; + a[tetris->x-2][tetris->y]=b[3]; + break; + } + case 6: /* ˳ʱ180Tַ + */ + { + color(11); + a[tetris->x][tetris->y-1]=b[1]; + a[tetris->x-2][tetris->y]=b[2]; + a[tetris->x+2][tetris->y]=b[3]; + break; + } + case 7: /* ˳ʱ270Tַ + + */ + { + color(11); + a[tetris->x][tetris->y-1]=b[1]; + a[tetris->x][tetris->y+1]=b[2]; + a[tetris->x+2][tetris->y]=b[3]; + break; + } + case 8: /* Zַ + */ + { + color(14); + a[tetris->x][tetris->y+1]=b[1]; + a[tetris->x-2][tetris->y]=b[2]; + a[tetris->x+2][tetris->y+1]=b[3]; + break; + } + case 9: /* ˳ʱZַ + + */ + { + color(14); + a[tetris->x][tetris->y-1]=b[1]; + a[tetris->x-2][tetris->y]=b[2]; + a[tetris->x-2][tetris->y+1]=b[3]; + break; + } + case 10: /* תZַ + */ + { + color(14); + a[tetris->x][tetris->y-1]=b[1]; + a[tetris->x-2][tetris->y-1]=b[2]; + a[tetris->x+2][tetris->y]=b[3]; + break; + } + case 11: /* ˳ʱZַ + + */ + { + color(14); + a[tetris->x][tetris->y+1]=b[1]; + a[tetris->x-2][tetris->y-1]=b[2]; + a[tetris->x-2][tetris->y]=b[3]; + break; + } + case 12: /* 7ַ + + */ + { + color(12); + a[tetris->x][tetris->y-1]=b[1]; + a[tetris->x][tetris->y+1]=b[2]; + a[tetris->x-2][tetris->y-1]=b[3]; + break; + } + case 13: /* ˳ʱ907ַ + */ + { + color(12); + a[tetris->x-2][tetris->y]=b[1]; + a[tetris->x+2][tetris->y-1]=b[2]; + a[tetris->x+2][tetris->y]=b[3]; + break; + } + case 14: /* ˳ʱ1807ַ + + */ + { + color(12); + a[tetris->x][tetris->y-1]=b[1]; + a[tetris->x][tetris->y+1]=b[2]; + a[tetris->x+2][tetris->y+1]=b[3]; + break; + } + case 15: /* ˳ʱ2707ַ + */ + { + color(12); + a[tetris->x-2][tetris->y]=b[1]; + a[tetris->x-2][tetris->y+1]=b[2]; + a[tetris->x+2][tetris->y]=b[3]; + break; + } + case 16: /* ת7ַ + + */ + { + color(12); + a[tetris->x][tetris->y+1]=b[1]; + a[tetris->x][tetris->y-1]=b[2]; + a[tetris->x+2][tetris->y-1]=b[3]; + break; + } + case 17: /* ˳ʱת907ַ + */ + { + color(12); + a[tetris->x-2][tetris->y]=b[1]; + a[tetris->x+2][tetris->y+1]=b[2]; + a[tetris->x+2][tetris->y]=b[3]; + break; + } + case 18: /* ˳ʱת1807ַ + + */ + { + color(12); + a[tetris->x][tetris->y-1]=b[1]; + a[tetris->x][tetris->y+1]=b[2]; + a[tetris->x-2][tetris->y+1]=b[3]; + break; + } + case 19: /* ˳ָת2707ַ + */ + { + color(12); + a[tetris->x-2][tetris->y]=b[1]; + a[tetris->x-2][tetris->y-1]=b[2]; + a[tetris->x+2][tetris->y]=b[3]; + break; + } + } } @@ -364,114 +435,142 @@ void PrintTetris(struct Tetris *tetris){ } -/******жϷܷƶ******/ +/** + * жǷƶ + */ int ifMove(struct Tetris *tetris) { - if(a[tetris->x][tetris->y]!=0){ - return 0; - } - else{ - if( - (tetris->flag==1&&(a[tetris->x][tetris->y-1]==0&& - a[tetris->x][tetris->y-1]==0&&a[tetris->x+2][tetris->y]==0))|| - (tetris->flag==2&&(a[tetris->x-2][tetris->y]==0&& - a[tetris->x+2][tetris->y]==0&&a[tetris->x+4][tetris->y]==0))|| - (tetris->flag==3&&(a[tetris->x][tetris->y-1]==0&& - a[tetris->x][tetris->y-2]==0&&a[tetris->x][tetris->y+1]==0))|| - (tetris->flag==4&&(a[tetris->x-2][tetris->y]==0&& - a[tetris->x+2][tetris->y]==0&&a[tetris->x][tetris->y+1]==0))|| - (tetris->flag==5&&(a[tetris->x][tetris->y-1]==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&& - a[tetris->x-2][tetris->y]==0&&a[tetris->x+2][tetris->y]==0))|| - (tetris->flag==7&&(a[tetris->x][tetris->y-1]==0&& - a[tetris->x][tetris->y+1]==0&&a[tetris->x+2][tetris->y]==0))|| - (tetris->flag==8&&(a[tetris->x][tetris->y+1]==0&& - a[tetris->x-2][tetris->y]==0&&a[tetris->x+2][tetris->y+1]==0))|| - (tetris->flag==9&&(a[tetris->x][tetris->y-1]==0&& - a[tetris->x-2][tetris->y]==0&&a[tetris->x-2][tetris->y+1]==0))|| - (tetris->flag==10&&(a[tetris->x][tetris->y-1]==0&& - a[tetris->x-2][tetris->y-1]==0&&a[tetris->x+2][tetris->y]==0))|| - (tetris->flag==11&&(a[tetris->x][tetris->y+1]==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&& - 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&& - 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&& - 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&& - 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&& - 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&& - 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&& - 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&& - a[tetris->x-2][tetris->y-1]==0&&a[tetris->x+2][tetris->y]==0))) - { - return 1; - } + if(a[tetris->x][tetris->y]!=0)//ķλͼʱֵΪ0ƶ + { + return 0; + } + else + { + if( + ( tetris->flag==1 && ( a[tetris->x][tetris->y-1]==0 &&/*Ϊַҳķλ +⣬""ַλͼʱ˵λַܹ飬ƶλãֵΪ1 +ƶ*/ + a[tetris->x+2][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 ) ) || + ( tetris->flag==3 && ( a[tetris->x][tetris->y-1]==0 && //ֱ߷飨 + a[tetris->x][tetris->y-2]==0 && a[tetris->x][tetris->y+1]==0 ) ) || + ( tetris->flag==4 && ( a[tetris->x-2][tetris->y]==0 && //Tַ + a[tetris->x+2][tetris->y]==0 && a[tetris->x][tetris->y+1]==0 ) ) || + ( tetris->flag==5 && ( a[tetris->x][tetris->y-1]==0 && //Tַ飨˳ʱ90㣩 + 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㣩 + a[tetris->x-2][tetris->y]==0 && a[tetris->x+2][tetris->y]==0 ) ) || + ( tetris->flag==7 && ( a[tetris->x][tetris->y-1]==0 && //Tַ飨˳ʱ270㣩 + a[tetris->x][tetris->y+1]==0 && a[tetris->x+2][tetris->y]==0 ) ) || + ( tetris->flag==8 && ( a[tetris->x][tetris->y+1]==0 && //Zַ + a[tetris->x-2][tetris->y]==0 && a[tetris->x+2][tetris->y+1]==0 ) ) || + ( tetris->flag==9 && ( a[tetris->x][tetris->y-1]==0 && //Zַ飨˳ʱ180㣩 + a[tetris->x-2][tetris->y]==0 && a[tetris->x-2][tetris->y+1]==0 ) ) || + ( tetris->flag==10 && ( a[tetris->x][tetris->y-1]==0 && //Zַ飨ת + a[tetris->x-2][tetris->y-1]==0 && a[tetris->x+2][tetris->y]==0 ) ) || + ( tetris->flag==11 && ( a[tetris->x][tetris->y+1]==0 &&//Zַ飨ת+˳ʱ180㣩 + 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ַ + 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㣩 + 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㣩 + 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㣩 + 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ַ飨ת + 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㣩 + 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 0; -} + return 0; +} -/*******˹ĺۼ********/ -void CleanTetris(struct Tetris *tetris){ - for(i=0;i<4;i++){ - b[i]=0; - } - MakeTetris(tetris); - for(i=tetris->x-2;i<=tetris->x+4;i+=2){ - for(tetris->y-2;i<=tetris->y+1;j++){ - if(a[i][j]==0&&j>FrameY){ - gotoxy(i,j); - printf(" "); - } - } - } -} + +void CleanTetris(struct Tetris *tetris) +{ + for(i=0;i<4;i++) //b[4]4Ԫأѭ4ԪأÿԪصֵΪ0 + { + b[i]=0; //b[4]ÿԪصֵΪ0 + } + MakeTetris(tetris); //˹ + for( i = tetris->x - 2;i <= tetris->x + 4; i+=2 ) //X XΪķ + { + for(j = tetris->y-2;j <= tetris->y + 1;j++) /* + + X + */ + { + if( a[i][j] == 0 && j > FrameY ) //λûͼҴϷ浱 + { + gotoxy(i,j); + printf(" "); // + } + } + } +} -/*******жǷ********/ -void Del_Fullline(struct Tetris *tetris){ - int k,del_rows=0; - for(j=FrameY+Frame_height-1;j>=FrameY+1;j--){ - k=0; - for(i=FrameX+2;iFrameY;k--){ - for(i=FrameX+2;iscore+=100*del_rows; - if(del_rows>0&&(tetris->score%1000==0||tetris->score/1000>tetris->level-1)){ - tetris->speed-+20; - tetris->level++; - } +/** + * жǷвɾеĶ˹ + */ +void Del_Fullline(struct Tetris *tetris) //ijFrame_width-2ʱ +{ + int k,del_rows=0; //ֱڼ¼ijзĸɾı + for(j=FrameY+Frame_height-1;j>=FrameY+1;j--) + { + k=0; + for(i=FrameX+2;iFrameY;k--) + { + for(i=FrameX+2;iscore+=100*del_rows; //ÿɾһУ100 + if( del_rows>0 && ( tetris->score%1000==0 || tetris->score/1000>tetris->level-1 ) ) + { //1000ּۼɾ10Уٶȼӿ20msһ + tetris->speed-=20; + tetris->level++; + } } @@ -486,142 +585,181 @@ void Flag(struct Tetris *tetris){ } -/*******ʼϷ*******/ -void Gameplay(){ +/** + * ʼϷ + */ +void Gameplay() +{ int n; - struct Tetris t,*tetris=&t; - char ch; - tetris->number=0; - tetris->speed=300; - tetris->score=0; - tetris->level=1; - while(1){ - Flag(tetris); - Temp=tetris->flag; - tetris->x=FrameX+2*Frame_width+6; - tetris->y=FrameY+10; - tetris->flag=tetris->next; - PrintTetris(tetris); - tetris->x=FrameX+Frame_width; - tetris->y=FrameY-1; - tetris->flag=Temp; - /******ȡ̰*******/ - while(1){ - label:PrintTetris(tetris); - Sleep(tetris->speed);//ʱ - CleanTetris(tetris); - Temp1=tetris->x; - Temp2+tetris->flag; - if(kbhit()){ - ch=getch(); - if(ch==75){ - tetris->x-=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(tetris->flag>=2&&tetris->flag<=3){ - tetris->flag++; - tetris->flag%=2; - tetris->flag+=2; - }//ֱ߷ - if(tetris->flag>=4&&tetris->flag<=7){ - tetris->flag++; - tetris->flag%=4; - tetris->flag+=4; - }//Tַ - if(tetris->flag>=8&&tetris->flag<=11){ - tetris->flag++; - tetris->flag%=4; - tetris->flag+=8; - }//Zַ - if(tetris->flag>=12&&tetris->flag<=15){ - tetris->flag++; - tetris->flag%=4; - tetris->flag+=12; - }// 7ַ - if(tetris->flag>=16&&tetris->flag<=19){ - tetris->flag++; - tetris->flag%=4; - tetris->flag+=16; - }//7ַ - } - if(ch==32) //ոͣ - { - PrintTetris(tetris); - while(1){ - if(kbhit()){ - ch=getch(); - if(ch==32) goto label; - } + struct Tetris t,*tetris=&t; //ṹָ벢ָṹ + char ch; //ռı + tetris->number=0; //ʼ˹Ϊ0 + tetris->speed=300; //ʼƶٶΪ300ms + tetris->score=0; //ʼϷķΪ0 + tetris->level=1; //ʼϷΪ1 + while(1) //ѭ飬ֱϷ + { + Flag(tetris); //õ˹͵ + Temp=tetris->flag; //סǰ˹ + tetris->x=FrameX+2*Frame_width+6; //Ԥ淽x + tetris->y=FrameY+10; //Ԥ淽y + tetris->flag = tetris->next; //һ˹ + PrintTetris(tetris); //ôӡ˹鷽 + tetris->x=FrameX+Frame_width; //Ϸķx + tetris->y=FrameY-1; //Ϸķy + tetris->flag=Temp; // + while(1) //Ʒ鷽ֱ鲻 + { + label:PrintTetris(tetris); //ӡ˹ + Sleep(tetris->speed); //ӻʱ + CleanTetris(tetris); //ۼ + Temp1=tetris->x; //סķֵ + Temp2=tetris->flag; //סǰ˹ + if(kbhit()) //жǷм룬ch + { + ch=getch(); + if(ch==75) // 󶯣ĺ2 + { + tetris->x-=2; + } + if(ch==77) // Ҷĺ2 + { + tetris->x+=2; + } + if(ch==80) // + { + if(ifMove(tetris)!=0) + { + tetris->y+=2; } - } - if(ch==27){ //ESC˳Ϸ + if(ifMove(tetris)==0) + { + tetris->y=FrameY+Frame_height-2; + } + } + if(ch==72) // ,ǰ˳ʱת90 + { + if( tetris->flag>=2 && tetris->flag<=3 ) //ֱ߷ + { + tetris->flag++; + tetris->flag%=2; + tetris->flag+=2; + } + if( tetris->flag>=4 && tetris->flag<=7 ) //Tַ + { + tetris->flag++; + tetris->flag%=4; + tetris->flag+=4; + } + if( tetris->flag>=8 && tetris->flag<=11 ) //Zַ + { + tetris->flag++; + tetris->flag%=4; + tetris->flag+=8; + } + if( tetris->flag>=12 && tetris->flag<=15 ) //7ַ + { + tetris->flag++; + tetris->flag%=4; + tetris->flag+=12; + } + if( tetris->flag>=16 && tetris->flag<=19 ) //Ƿ7ַ + { + tetris->flag++; + tetris->flag%=4; + tetris->flag+=16; + } + } + if(ch == 32) //ոͣ + { + PrintTetris(tetris); + while(1) + { + if(kbhit()) //ٰոϷ + { + ch=getch(); + if(ch == 32) + { + goto label; + } + } + } + } + if(ch == 27) + { system("cls"); - memset(a,0,6400*sizeof(int));//ʼ + memset(a,0,6400*sizeof(int)); + title(); //ʼa welcome(); } - if(ifMove(tetris)==0){ - tetris->x=Temp1; - tetris->flag=Temp2; - } - else{ - goto label; - } - } - tetris->y++; - if(ifMove(tetris)==0){ - tetris->y--; - PrintTetris(tetris); - Del_Fullline(tetris); - break; - } - } - //Ϸ - for(i=tetris->y-2;iy+2;i++){ - if(i==FrameY){ - system("cls"); - gotoxy(29,7); - printf(" \n"); - 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"); - gotoxy(17,18); - color(14); - printf("Ҫһ---------1"); - gotoxy(44,18); - printf("ˣ˳-----------2\n"); - int n; - gotoxy(32,20); - printf("ѡ1/2"); - color(11); - scanf("%d",&n); - switch(n){ - case 1: - system("cls"); - Replay(tetris); - break; - case 2: - exit(0); - break; - } - } - } - tetris->flag=tetris->next; - tetris->x=FrameX+2*Frame_width+6; - tetris->y=FrameY+10; - CleanTetris(tetris); - } + if(ifMove(tetris)==0) //ɶЧ + { + tetris->x=Temp1; + tetris->flag=Temp2; + } + else //ɶִв + { + goto label; + } + } + tetris->y++; //ûвָƶ + if(ifMove(tetris)==0) //ƶҲɶڴ˴ + { + tetris->y--; + PrintTetris(tetris); + Del_Fullline(tetris); + break; + } + }//Ϸ鴥λ +for(i=tetris->y-2;iy+2;i++) + { + if(i==FrameY) + { + system("cls"); // + gotoxy(29,7); //ʾλ + printf(" \n"); + 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"); + gotoxy(17,18); + color(14); + printf("Ҫһ-------1"); + gotoxy(44,18); + printf("ˣ˳-------2\n"); + int n; + gotoxy(32,20); + printf("ѡ1/2"); + color(11); + scanf("%d", &n); //12 + switch (n) //֧ + { + case 1: + system("cls"); + Replay(tetris); //¿ʼϷ + break; + case 2: + exit(0); + break; + } + } + } + tetris->flag = tetris->next; //һ˹ͼ(ұߴ) + tetris->x=FrameX+2*Frame_width+6; + tetris->y=FrameY+10; + CleanTetris(tetris); + } +} + + +/*******¿ʼϷ*******/ +void Replay(struct Tetris *tetris){ + system("cls"); + memset(a,0,6400*sizeof(int)); + DrawGameframe(); + Gameplay(); } diff --git a/俄罗斯方块.o b/俄罗斯方块.o index 52df586..6ac7c79 100644 Binary files a/俄罗斯方块.o and b/俄罗斯方块.o differ