int common_check(int direction)
{
int ii,kk,ff;
int[,] tristmp = new int[MAPY,MAPX];
for(ii=0; ii<MAPY; ii++)
for(kk=0; kk<MAPX; kk++)
{
tristmp[ii,kk]=tris[ii,kk]; }
for(ii=0; ii<ARR; ii++)
for(kk=0; kk<ARR; kk++)
{
//Index Array Exception//Index Array Exception//Index Array Exception
if(ypos+ii >MAPY-1) continue;
if(xpos+kk > MAX-1) continue;
if(xpos+kk < 0) continue;
if(design[ii,kk]==1) tristmp[ypos+ii,xpos+kk]=0; }
if(direction==D_RIGHT) xpos++;
if(direction==D_LEFT) xpos--;
if(direction==D_DOWN) ypos++;
for(ii=0; ii<ARR; ii++)
for(kk=0; kk<ARR; kk++)
{
//Index Array Exception//Index Array Exception//Index Array Exception
if(ypos+ii >MAPY-1) continue;
if(xpos+kk > MAX-1) continue;
if(xpos+kk < 0) continue;
if(design[ii,kk]==1) tristmp[ypos+ii,xpos+kk] += 1; }
ff=0;
for(ii=0; ii<ARR; ii++)
for(kk=0; kk<ARR; kk++)
{
//Index Array Exception//Index Array Exception//Index Array Exception
if(ypos+ii >MAPY-1) continue;
if(xpos+kk > MAX-1) continue;
if(xpos+kk < 0) continue;
if(tristmp[ypos+ii,xpos+kk] > 1) ff++;
}
if(ff>0)
{
if(direction==D_RIGHT) xpos--;
if(direction==D_LEFT) xpos++;
if(direction==D_DOWN) ypos--;
return(FAIL);
}
else
{
for(ii=0; ii<MAPY; ii++)
for(kk=0; kk<MAPX; kk++)
{ tris[ii,kk]=tristmp[ii,kk] }
}
return(SUCC);
}
Ex)
void tris_time_tick(object sender, ElapsedEventArgs e)
{
int rc;
draw();
rc= common_check(D_DOWN);
if(rc == FAIL)
{
if(ypos== 0) stop();
else
{
while(true)
{
if(check_horizon()==FAIL) break;
}
____init("L");
}
}
}
'c# 언어' 카테고리의 다른 글
TrisPackage.Tris/delete_column(); (0) | 2021.11.19 |
---|---|
TrisPackage.Tris/definition/variables/controls (0) | 2021.11.17 |
TrisPackage.Tris/check_horizon(); (0) | 2021.11.17 |
TrisPackage.Tris/tris_time_tick(); (0) | 2021.11.17 |
TrisPackage.Tris/direct_check(); (0) | 2021.11.17 |