기 ¶
기 ¶
게 기 .
고, 과 거 각.
고, 과 거 각.
~cpp 1. 결. 2. next . 3.next . 4. . 5. . 6. , . 7. .
.
, 기게 길 .
, 기게 길 .
기 ¶
.
n 고, n ,
T(0,3)(1,1)(1,1)게 . , 거 꿔 .
그고 그 게 기 곳 고 곳 0 .
n 고, n ,
T(0,3)(1,1)(1,1)게 . , 거 꿔 .
그고 그 게 기 곳 고 곳 0 .
) . 길, 기 권.
~cpp {{ {0,0,0,0}, {2,2,2,2}, {0,0,0,0}, {0,0,0,0}} ,{ {0,0,2,0}, {0,0,2,0}, {0,0,2,0}, {0,0,2,0}} ,{ {0,0,0,0}, {2,2,2,2}, {0,0,0,0}, {0,0,0,0}} ,{ {0,0,2,0}, {0,0,2,0}, {0,0,2,0}, {0,0,2,0}} },
next 기 ¶
기 ¶
. .
간, 그 , 게 .
, x,y값 기 고 .
그고, 기 .
고 next 과 고 .
key_Left() 고, , .
)간, 그 , 게 .
, x,y값 기 고 .
그고, 기 .
고 next 과 고 .
key_Left() 고, , .
~cpp for (register int i=0;i<3; ++i) { for (register int j=0; j<4; ++j) { if (0!=block_type[prv_block][0][i][j]) { if (0==block[3+i][16+j]) block[3+i][16+j]=block_type[prv_block][0][i][j]; else game_end(); } } } x=3; // x y=16; // y shape=0; // now_block=prv_block; // ID
게 기 ¶
) . -1 0 , 1 겨.
.
~cpp int move_block(int where)// -1 0 1 { int temp_x=x+where; int temp_y=y-(where+1)%2; int temp_block[4][4]={0,}; int ground[4]={0,}; int side[2][4]={0,}; int swit[2][4]={0,}; // . for (register int i=0;i<4; ++i) { for (register int j=0; j<4; ++j) { if (0!=block_type[now_block][shape][i][j]) { if (i>=side[0][j] && 0==swit[1][j]) { side[0][j]=i; swit[1][j]=1; } side[1][j]=i; if (j>=ground[i] && 0==swit[0][i]) { ground[i]=j; swit[0][i]=1; } } } } // . 경 1 고 . for (i=0;i<4; ++i) { for (register int j=0; j<4; ++j) { if (0!=block_type[now_block][shape][i][j]) { if (temp_x+i<0 || temp_x+i>9 ) return 1; else if (temp_y+j<0 || temp_y+j>19 ) return 1; else if (0!=block[temp_x+i][temp_y+j]) { if (ground[i]+1>j && where==0) return 1; else if (side[0][j]+1>i && where==-1) return 1; else if (side[1][j]-1<i && where==1) return 1; } } } } // 거. for (i=0;i<4; ++i) for (register int j=0; j<4; ++j) if (0!=block_type[now_block][shape][i][j]) block[x+i][y+j]=0; // 그. for (i=0;i<4; ++i) for (register int j=0; j<4; ++j) if (0!=block_type[now_block][shape][i][j]) block[temp_x+i][temp_y+j]=block_type[now_block][shape][i][j]; x=temp_x;y=temp_y; return 0; }
게 기 ¶
기 , , 공간 고, 고 공간 게 . 간 , 기, .
)~cpp int temp_x=x; int temp_y=y; int temp_shape=(shape+1)%4; int crash=2; int temp_block[4][4]={0,}; // , 공간 . while (2==crash) { for (register int i=0;i<4; ++i) for (register int j=0; j<4; ++j) temp_block[i][j]=0; crash=0; for (i=0;i<4; ++i) for (register int j=0; j<4; ++j) if (0!=block_type[now_block][shape][i][j]&& 0<=i+x-temp_x && 3>=i+x-temp_x ) temp_block[i+x-temp_x][j]=1; for (i=0;i<4; ++i) { for (register int j=0; j<4; ++j) { if (0!=block_type[now_block][temp_shape][i][j]) { if (temp_x+i<0) { temp_x+=1;crash=2; } else if (temp_x+i>9 ) { temp_x-=1;crash=2; } else if (0!=block[temp_x+i][temp_y+j] && 1!=temp_block[i][j]) crash=1; } } } } // 공간 , . if (1==crash) return 0; for (register int i=0;i<4; ++i) for (register int j=0; j<4; ++j) if (0!=block_type[now_block][shape][i][j]) block[x+i][y+j]=0; // 그. for (i=0;i<4; ++i) for (register int j=0; j<4; ++j) if (0!=block_type[now_block][temp_shape][i][j]) block[temp_x+i][temp_y+j]=block_type[now_block][temp_shape][i][j]; // 값 . x=temp_x;y=temp_y;shape=temp_shape; return 0;
기 ¶
게 , . , 그 .
for , 경, .
)for , 경, .
~cpp void delete_block() { for (register int line=y; line<y+4; ++line) for (register int i=0; i<10; ++i) if (0==block[i][line]) i=10; // , 그 . else if (9==i) // 경 . { for (register int k=0; k<10; ++k) block[k][line]=0; for (k=line; k<19; ++k) // . for (register int l=0; l<10; ++l) block[l][k]=block[l][k+1]; for (k=0; k<10; ++k) block[k][19]=0; --line; } }
¶
, 경 고, 그 경 값 .
그고 그 결과 꾸고, time_delay 값 감 .
그고 그 결과 꾸고, time_delay 값 감 .