화 하 ¶
할 하 ¶
행하 해 할 해 할 .
테트 , 해.
테트 , 해.
~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 키 .














