diff --git a/俄罗斯方块.c b/俄罗斯方块.c index a0675c1..519ae73 100644 --- a/俄罗斯方块.c +++ b/俄罗斯方块.c @@ -334,7 +334,7 @@ void MakeTetris(struct Tetris *tetris){ /******ӡ˹*******/ -void PrintfTetris(struct Tetris *tetris){ +void PrintTetris(struct Tetris *tetris){ for(i=0;i<4;i++) b[i]=1; MakeTetris(tetris); for(i=tetris->x-2;i<=tetris->x+4;i+=2){ @@ -367,7 +367,7 @@ void PrintfTetris(struct Tetris *tetris){ /******жϷܷƶ******/ int ifMove(struct Tetris *tetris) { - if(a[tetris->flag][tetris->y]!=0){ + if(a[tetris->x][tetris->y]!=0){ return 0; } else{ @@ -436,7 +436,7 @@ void CleanTetris(struct Tetris *tetris){ /*******жǷ********/ -void Del_Fulline(struct Tetris *tetris){ +void Del_Fullline(struct Tetris *tetris){ int k,del_rows=0; for(j=FrameY+Frame_height-1;j>=FrameY+1;j--){ k=0; @@ -486,6 +486,145 @@ void Flag(struct Tetris *tetris){ } +/*******ʼϷ*******/ +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; + } + } + } + if(ch==27){ //ESC˳Ϸ + system("cls"); + memset(a,0,6400*sizeof(int));//ʼ + 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); + } +} + + /**************/ int main(){ title(); diff --git a/俄罗斯方块.o b/俄罗斯方块.o index 077897d..52df586 100644 Binary files a/俄罗斯方块.o and b/俄罗斯方块.o differ