2019-08-05
View Code
1 /*******************************/ 2 /******Writer: GJ *******/ 3 /******Language: C *******/ 4 /******Date: 2013 3 23 *******/ 5 /*******************************/ 6 #include<iostream> 7 #include<stdio.h> 8 //#include<conio.h> 9 #include<string.h> 10 #include<time.h> 11 #include<stdlib.h> 12 #include<windows.h> 13 using namespace std; 14 #define me(a) memset(a,0,sizeof(a)) 15 #define judge(bl,ok) for(i=0;i<5;i++)if(bl[i].x&&map[bl[i].x][bl[i].y])ok=0 16 #define is_pure(node,ok) if(map[node.x][node.y])ok=0 17 const int HEIGHT=24,LENGTH=40,SIDE=22; 18 19 char INIT_MAP[HEIGHT+1][LENGTH+1]; 20 int map[HEIGHT][SIDE]; 21 struct node{int x,y;int color;}; 22 const int TIME_DWELL=1000; 23 int state=0; 24 25 /**********获取句柄**********/ 26 HANDLE Output=GetStdHandle(STD_OUTPUT_HANDLE); 27 HANDLE Input=GetStdHandle(STD_INPUT_HANDLE); 28 29 /**********设置光标位置**********/ 30 void SetCursor(int x,int y){ 31 COORD cd={x,y}; 32 SetConsoleCursorPosition(Output,cd); 33 } 34 35 /**************初始化图**************/ 36 void INITMAP() 37 { 38 for(int i=0;i<HEIGHT;i++) 39 for(int j=0;j<SIDE;j++){ 40 if(i==0||i==HEIGHT-1||j==0||j==SIDE-1)map[i][j]=1; 41 else map[i][j]=0; 42 } 43 } 44 45 /********右上方提前显示方块******/ 46 node bl[5]; 47 void Former_Print_block(int n) 48 { 49 int i; 50 for(i=0;i<5;i++){bl[i].x=bl[i].y=0;} 51 if(n==0){ 52 bl[0].x=3,bl[0].y=28; bl[1].x=3,bl[1].y=30; 53 bl[2].x=4,bl[2].y=30; bl[3].x=4,bl[3].y=32; 54 } 55 if(n==1){ 56 bl[0].x=3,bl[0].y=32; bl[1].x=3,bl[1].y=30; 57 bl[2].x=4,bl[2].y=30; bl[3].x=4,bl[3].y=28; 58 } 59 if(n==2){ 60 bl[0].x=3,bl[0].y=30; bl[1].x=4,bl[1].y=28; 61 bl[2].x=4,bl[2].y=30; bl[3].x=4,bl[3].y=32; 62 } 63 if(n==3){ 64 bl[0].x=3,bl[0].y=27; bl[1].x=3,bl[1].y=29; 65 bl[2].x=3,bl[2].y=31; bl[3].x=3,bl[3].y=33; 66 } 67 if(n==4){ 68 bl[0].x=3,bl[0].y=29; bl[1].x=3,bl[1].y=31; 69 bl[2].x=4,bl[2].y=29; bl[3].x=4,bl[3].y=31; 70 } 71 if(n==5){ 72 bl[0].x=3,bl[0].y=28; bl[1].x=4,bl[1].y=28; 73 bl[2].x=4,bl[2].y=30; bl[3].x=4,bl[3].y=32; 74 } 75 if(n==6){ 76 bl[0].x=3,bl[0].y=32; bl[1].x=4,bl[1].y=28; 77 bl[2].x=4,bl[2].y=30; bl[3].x=4,bl[3].y=32; 78 } 79 for(i=0;i<5;i++){ 80 SetCursor(bl[i].y,bl[i].x); 81 printf("[]"); 82 } 83 } 84 85 /*********获取不同的方块,出现在中间***********/ 86 node block[5];//全局使用的核心!!!
2019-08-0522:26:38