From a58d1cc502ac7c07bccc4fd68174232cdfe56114 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Jan 2019 08:54:34 +0800 Subject: [PATCH] first commit --- 俄罗斯方块游戏.c | 60 ++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/俄罗斯方块游戏.c b/俄罗斯方块游戏.c index d1743d2..92c9fc1 100644 --- a/俄罗斯方块游戏.c +++ b/俄罗斯方块游戏.c @@ -23,12 +23,9 @@ struct Tetris int score; //Ϸķ int level; //Ϸĵȼ } ; -struct jilu_info - { - int first; - int second; - int third; - }jilu={0,0,0}; + int first; + int second; + int third; HANDLE hOut; //̨ /********/ void HideCursor(); //ع @@ -45,7 +42,7 @@ void Clean(struct Tetris *); // int If_move(struct Tetris *); //жǷƶ10 void Shui_Ji(struct Tetris *); // void Full(struct Tetris *); // жϷǷ -void tihuan(int x); +void tihuan(int n,int x,int y,int z); void panduan(int x); /*ؿ̨Ĺ*/ void HideCursor() @@ -74,6 +71,9 @@ int main() { HideCursor(); + FILE *fp; + fp=fopen("f1.txt","w"); + fclose(fp); /*ͼ*/ color(11); gotoxy(20,3); @@ -284,17 +284,17 @@ void Ji_Lu() } } FILE *fp; - fp=fopen("f1.txt","w"); - fscanf(fp,"%d%d%d",&jilu.first,&jilu.second,&jilu.third); + fp=fopen("f1.txt","r+"); + fscanf(fp,"%d%d%d",&first,&second,&third); color(12); gotoxy(30,9); - printf("һ %d",jilu.first); + printf("һ %d",first); color(10); gotoxy(30,12); - printf("ڶ %d",jilu.second); + printf("ڶ %d",second); color(11); gotoxy(30,15); - printf(" %d",jilu.third); + printf(" %d",third); fclose(fp); getch(); // system("cls"); @@ -302,17 +302,21 @@ void Ji_Lu() } /*ж*/ -void panduan(int x) +void panduan(int n) { FILE *fp; - fp=fopen("f1.txt","w"); - fscanf(fp,"%d%d%d",&jilu.first,&jilu.second,&jilu.third); - if(x>jilu.third) + fp=fopen("f1.txt","r"); + fscanf(fp,"%d%d%d",&first,&second,&third); + fclose(fp); + if(n>third) { printf("һ¼Ŷ!!!"); - tihuan(x); + tihuan(n,first,second,third); + fp=fopen("f1.txt","w"); + fprintf(fp,"%d %d %d",first,second,third); + fclose(fp); } - fclose(fp); + } /*Ϸ */ @@ -762,22 +766,22 @@ for(i=tetris->y-2;iy+2;i++) } } -void tihuan(int x) +void tihuan(int n,int x,int y,int z) { - if(x>jilu.first) + if(n>x) { - jilu.third =jilu.second; - jilu.second =jilu.first; - jilu.first =x; + z=y; + y =x; + x=n; } - else if(xjilu.second ) + else if(ny ) { - jilu.third =jilu.second ; - jilu.second =x; + z =y; + y =n; } - else if(xjilu.third ) + else if(nz ) { - jilu.third =x; + z=n; } } /*ۼ*/