diff --git a/俄罗斯方块游戏.cpp b/俄罗斯方块游戏.c similarity index 95% rename from 俄罗斯方块游戏.cpp rename to 俄罗斯方块游戏.c index 7344daa..64bf51a 100644 --- a/俄罗斯方块游戏.cpp +++ b/俄罗斯方块游戏.c @@ -1,9 +1,8 @@ -/****ͷļ****/ #include #include #include #include -/****궨****/ + #define FrameX 13 //ϷϽǵXΪ13 #define FrameY 3 //ϷϽǵYΪ3 #define Frame_height 20 //Ϸڵĸ߶Ϊ20 @@ -25,18 +24,18 @@ struct Tetris } ; HANDLE hOut; //̨ /********/ -void HideCursor(); +void HideCursor(); //ع int color(int c); //ɫ void gotoxy(int x,int y); //ȡĻλ void Game(); //Ϸ -void play(); //ʼϷ +void Play(); //ʼϷ void explation(); //˵ void rule(); //Ϸ void Make(struct Tetris *); // void Print(struct Tetris *); //ӡ void Clean(struct Tetris *); //ۼ -int ifMove(struct Tetris *); //жǷƶ10 -void Flag(struct Tetris *); // +int If_move(struct Tetris *); //жǷƶ10 +void Shui_Ji(struct Tetris *); // void Full(struct Tetris *); // жϷǷ /*ؿ̨Ĺ*/ @@ -61,8 +60,6 @@ void gotoxy(int x,int y) SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos); } - - /*ҳ */ int main() { @@ -169,7 +166,7 @@ int main() case 1: system("cls"); Game(); - play(); + Play(); break; case 2: explation(); @@ -253,6 +250,7 @@ void rule() system("cls"); main(); } + /*Ϸ */ void Game() { @@ -520,7 +518,7 @@ void Make(struct Tetris *tetris) } /* ʼϷ*/ -void play() +void Play() { int n; struct Tetris t,*tetris=&t; @@ -532,7 +530,7 @@ void play() HideCursor(); while(1) { - Flag(tetris); + Shui_Ji(tetris); Temp=tetris->flag; tetris->x=FrameX+2*Frame_width+6; tetris->y=FrameY+10; @@ -545,7 +543,7 @@ void play() while(1) { loop:Print(tetris); - Sleep(tetris->speed); + Sleep(tetris->speed); //ʱ Clean(tetris); Temp1=tetris->x; Temp2=tetris->flag; //סǰ˹ @@ -562,11 +560,11 @@ void play() } if(ch==80) // { - if(ifMove(tetris)!=0) + if(If_move(tetris)!=0) { tetris->y+=2; } - if(ifMove(tetris)==0) + if(If_move(tetris)==0) { tetris->y=FrameY+Frame_height-2; } @@ -579,30 +577,42 @@ void play() 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ַ + + if( tetris->flag>=8 && tetris->flag<=9 ) //Zַ { tetris->flag++; - tetris->flag%=4; + tetris->flag%=2; tetris->flag+=8; } + + if( tetris->flag>=10 && tetris->flag<=11 ) //ǷZַ + { + tetris->flag++; + tetris->flag%=2; + tetris->flag+=10; + } + 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) //ոͣ { @@ -625,7 +635,7 @@ void play() memset(a,0,6400*sizeof(int)); //ʼa main(); } - if(ifMove(tetris)==0) + if(If_move(tetris)==0) { tetris->x=Temp1; tetris->flag=Temp2; @@ -636,7 +646,7 @@ void play() } } tetris->y++; - if(ifMove(tetris)==0) + if(If_move(tetris)==0) { tetris->y--; Print(tetris); @@ -676,7 +686,7 @@ for(i=tetris->y-2;iy+2;i++) system("cls"); memset(a,0,6400*sizeof(int)); Game(); - play(); + Play(); } else exit(0); @@ -697,11 +707,11 @@ void Clean(struct Tetris *tetris) b[i]=0; //b[4]ÿԪصֵΪ0 } Make(tetris); - for( i = tetris->x - 2;i <= tetris->x + 4; i+=2 ) // XΪķ + for(i=tetris->x-2;i<=tetris->x+4;i+=2) // XΪķ { - for(j = tetris->y-2;j <= tetris->y + 1;j++) + for(j=tetris->y-2;j<=tetris->y+1;j++) { - if( a[i][j] == 0 && j > FrameY ) //λûͼҴϷ浱 + if(a[i][j]==0&&j>FrameY) //λûͼҴϷ浱 { gotoxy(i,j); printf(" "); // @@ -711,7 +721,7 @@ void Clean(struct Tetris *tetris) } /* ˹*/ -void Flag(struct Tetris *tetris) +void Shui_Ji(struct Tetris *tetris) { tetris->number++; //סĸ srand(time(NULL)); //ʼ @@ -723,7 +733,7 @@ void Flag(struct Tetris *tetris) } /*жϷǷƶ */ -int ifMove(struct Tetris *tetris) +int If_move(struct Tetris *tetris) { if(a[tetris->x][tetris->y]!=0) { @@ -873,6 +883,7 @@ int ifMove(struct Tetris *tetris) } return 0; } + /*жϷǷ */ void Full(struct Tetris *tetris) {