📄 lian.c
字号:
IsLink21p41();
IsLink21p42();
IsLink1p41();
IsLink1p42();
} /* of left-down */
} /* of x and y != */
else if(selected1x==selected2x)
{
IsLink21p11();
IsLink21p12();
IsLink0p1();
} /* of 1x = 2x */
else /* selected1y = selected2y */
{
IsLink21p21();
IsLink21p22();
IsLink0p2();
} /* of 1y = 2y */
selected1x = save1x;
selected1y = save1y;
selected2x = save2x;
selected2y = save2y;
return(LinkType);
}
/* ========================== */
void MatrixMove(void)
/* 0: not move
1: move down
2: move left
3: move outside up and down
4: move outside left and right
5: move inside up and down
6: move inside left and right
7: move up-left and down-right
8: move left-down and right-up
9: move outside
10: move inside
game is over !
*/
{
int ix,iy;
switch(guan)
{
case 0: break;
case 1: for(iy=MAX_Y;iy>1;iy--)
{
for(ix=1;ix<=MAX_X;ix++)
{
if(matrix[ix][iy]==0)
/* this unit is empty */
{
if(matrix[ix][iy-1]!=0)
{
matrix[ix][iy] = matrix[ix][iy-1];
matrix[ix][iy-1] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix;
unity = iy-1;
DrawUnit(EMPTY_CHAR);
}
else
/* the upper is empty too */
{
if(iy-2>=1)
{
if(matrix[ix][iy-2]!=0)
{
matrix[ix][iy] = matrix[ix][iy-2];
matrix[ix][iy-2] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix;
unity = iy-2;
DrawUnit(EMPTY_CHAR);
}
}
}
} /* of unit emppty */
} /* of for ix */
} /* of for iy */
break;
case 2: for(ix=1;ix<MAX_X;ix++)
{
for(iy=1;iy<=MAX_Y;iy++)
{
if(matrix[ix][iy]==0)
/* this unit is empty */
{
if(matrix[ix+1][iy]!=0)
{
matrix[ix][iy] = matrix[ix+1][iy];
matrix[ix+1][iy] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix+1;
unity = iy;
DrawUnit(EMPTY_CHAR);
}
else
/* the upper is empty too */
{
if(ix+2<=MAX_X)
{
if(matrix[ix+2][iy]!=0)
{
matrix[ix][iy] = matrix[ix+2][iy];
matrix[ix+2][iy] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix+2;
unity = iy;
DrawUnit(EMPTY_CHAR);
}
}
}
} /* of unit emppty */
} /* of for iy */
} /* of for ix */
break;
case 3: for(iy=1;iy<(MAX_Y/2);iy++)
{
for(ix=1;ix<=MAX_X;ix++)
{
if(matrix[ix][iy]==0)
/* this unit is empty */
{
if(matrix[ix][iy+1]!=0)
{
matrix[ix][iy] = matrix[ix][iy+1];
matrix[ix][iy+1] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix;
unity = iy+1;
DrawUnit(EMPTY_CHAR);
}
else
/* the upper is empty too */
{
if(iy+2<=MAX_Y/2)
{
if(matrix[ix][iy+2]!=0)
{
matrix[ix][iy] = matrix[ix][iy+2];
matrix[ix][iy+2] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix;
unity = iy+2;
DrawUnit(EMPTY_CHAR);
}
}
}
} /* of unit emppty */
} /* of for ix */
} /* of for iy */
for(iy=MAX_Y;iy>(MAX_Y/2)+1;iy--)
{
for(ix=1;ix<=MAX_X;ix++)
{
if(matrix[ix][iy]==0)
/* this unit is empty */
{
if(matrix[ix][iy-1]!=0)
{
matrix[ix][iy] = matrix[ix][iy-1];
matrix[ix][iy-1] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix;
unity = iy-1;
DrawUnit(EMPTY_CHAR);
}
else
/* the upper is empty too */
{
if(iy-2>=(MAX_Y/2)+1)
{
if(matrix[ix][iy-2]!=0)
{
matrix[ix][iy] = matrix[ix][iy-2];
matrix[ix][iy-2] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix;
unity = iy-2;
DrawUnit(EMPTY_CHAR);
}
}
}
} /* of unit emppty */
} /* of for ix */
} /* of for iy */
/* important remark: if MAX_Y is odd, exp: 9
line5 is go down, not go up */
break;
case 4: for(ix=1;ix<(MAX_X/2);ix++)
{
for(iy=1;iy<=MAX_Y;iy++)
{
if(matrix[ix][iy]==0)
/* this unit is empty */
{
if(matrix[ix+1][iy]!=0)
{
matrix[ix][iy] = matrix[ix+1][iy];
matrix[ix+1][iy] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix+1;
unity = iy;
DrawUnit(EMPTY_CHAR);
}
else
/* the upper is empty too */
{
if(ix+2<=MAX_X/2)
{
if(matrix[ix+2][iy]!=0)
{
matrix[ix][iy] = matrix[ix+2][iy];
matrix[ix+2][iy] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix+2;
unity = iy;
DrawUnit(EMPTY_CHAR);
}
}
}
} /* of unit emppty */
} /* of for iy */
} /* of for ix */
for(ix=MAX_X;ix>(MAX_X/2)+1;ix--)
{
for(iy=1;iy<=MAX_Y;iy++)
{
if(matrix[ix][iy]==0)
/* this unit is empty */
{
if(matrix[ix-1][iy]!=0)
{
matrix[ix][iy] = matrix[ix-1][iy];
matrix[ix-1][iy] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix-1;
unity = iy;
DrawUnit(EMPTY_CHAR);
}
else
/* the upper is empty too */
{
if(ix-2>=(MAX_X/2)+1)
{
if(matrix[ix-2][iy]!=0)
{
matrix[ix][iy] = matrix[ix-2][iy];
matrix[ix-2][iy] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix-2;
unity = iy;
DrawUnit(EMPTY_CHAR);
}
}
}
} /* of unit emppty */
} /* of for iy */
} /* of for ix */
/* important remark: if MAX_X is odd, exp: 15
line8 is go right or left? */
break;
case 5: for(iy=(MAX_Y/2);iy>1;iy--)
{
for(ix=1;ix<=MAX_X;ix++)
{
if(matrix[ix][iy]==0)
/* this unit is empty */
{
if(matrix[ix][iy-1]!=0)
{
matrix[ix][iy] = matrix[ix][iy-1];
matrix[ix][iy-1] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix;
unity = iy-1;
DrawUnit(EMPTY_CHAR);
}
else
/* the upper is empty too */
{
if(iy-2>=1)
{
if(matrix[ix][iy-2]!=0)
{
matrix[ix][iy] = matrix[ix][iy-2];
matrix[ix][iy-2] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix;
unity = iy-2;
DrawUnit(EMPTY_CHAR);
}
}
}
} /* of unit emppty */
} /* of for ix */
} /* of for iy */
for(iy=(MAX_Y/2)+1;iy<MAX_Y;iy++)
{
for(ix=1;ix<=MAX_X;ix++)
{
if(matrix[ix][iy]==0)
/* this unit is empty */
{
if(matrix[ix][iy+1]!=0)
{
matrix[ix][iy] = matrix[ix][iy+1];
matrix[ix][iy+1] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix;
unity = iy+1;
DrawUnit(EMPTY_CHAR);
}
else
/* the upper is empty too */
{
if(iy+2<=MAX_Y)
{
if(matrix[ix][iy+2]!=0)
{
matrix[ix][iy] = matrix[ix][iy+2];
matrix[ix][iy+2] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix;
unity = iy+2;
DrawUnit(EMPTY_CHAR);
}
}
}
} /* of unit emppty */
} /* of for ix */
} /* of for iy */
/* important remark: if MAX_Y is odd, exp: 9
line6 go up to line5, not line4 go down */
break;
case 6: for(ix=(MAX_X/2);ix>1;ix--)
{
for(iy=1;iy<=MAX_Y;iy++)
{
if(matrix[ix][iy]==0)
/* this unit is empty */
{
if(matrix[ix-1][iy]!=0)
{
matrix[ix][iy] = matrix[ix-1][iy];
matrix[ix-1][iy] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix-1;
unity = iy;
DrawUnit(EMPTY_CHAR);
}
else
/* the upper is empty too */
{
if(ix-2>=1)
{
if(matrix[ix-2][iy]!=0)
{
matrix[ix][iy] = matrix[ix-2][iy];
matrix[ix-2][iy] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix-2;
unity = iy;
DrawUnit(EMPTY_CHAR);
}
}
}
} /* of unit emppty */
} /* of for iy */
} /* of for ix */
for(ix=(MAX_X/2)+1;ix<MAX_X;ix++)
{
for(iy=1;iy<=MAX_Y;iy++)
{
if(matrix[ix][iy]==0)
/* this unit is empty */
{
if(matrix[ix+1][iy]!=0)
{
matrix[ix][iy] = matrix[ix+1][iy];
matrix[ix+1][iy] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix+1;
unity = iy;
DrawUnit(EMPTY_CHAR);
}
else
/* the upper is empty too */
{
if(ix+2<=MAX_X)
{
if(matrix[ix+2][iy]!=0)
{
matrix[ix][iy] = matrix[ix+2][iy];
matrix[ix+2][iy] = 0;
unitx = ix;
unity = iy;
DrawUnit(GetCharNum());
unitx = ix+2;
unity = iy;
DrawUnit(EMPTY_CHAR);
}
}
}
} /* of unit emppty */
} /* of for iy */
} /* of for ix */
/* important remark: if MAX_X is odd, exp: 15
line7 goto line8 or line9 goto line8? */
break;
default: break;
}
}
int ChooseFromBank(void)
/* choose one selected from the bank
how to choose is depend to the purpose of me
return: the position of chioce in the bank
*/
{
int ibank;
int ttype;
int miny,maxx,thisbank;
switch(guan)
{
case 0: for(ibank=0;ibank<BankCounter;ibank++)
{
ttype = SelectBank[ibank].type;
if(ttype>=7&&ttype<=12) return(ibank);
/* 1st: outside link type */
}
for(ibank=0;ibank<BankCounter;ibank++)
{
ttype = SelectBank[ibank].type;
if(ttype==1||ttype==2) return(ibank);
/* 2nd: -- or | link type */
}
break;
case 1: for(ibank=0;ibank<BankCounter;ibank++)
{
ttype = SelectBank[ibank].type;
if(ttype==9) return(ibank);
/* 1st: link up */
}
miny = MAX_Y;
thisbank = 0;
for(ibank=0;ibank<BankCounter;ibank++)
{
if(SelectBank[ibank].y1<miny)
{
miny = SelectBank[ibank].y1;
thisbank = ibank;
}
if(SelectBank[ibank].y2<miny)
{
miny = SelectBank[ibank].y2;
thisbank = ibank;
}
/* 2nd: upper -- the min y */
}
return(thisbank);
case 2: for(ibank=0;ibank<BankCounter;ibank++)
{
ttype = SelectBank[ibank].type;
if(ttype==8||ttype==11) return(ibank);
/* 1st: link right */
}
maxx = 1;
thisbank = 0;
for(ibank=0;ibank<BankCounter;ibank++)
{
if(SelectBank[ibank].x1>maxx)
{
maxx = SelectBank[ibank].x1;
thisbank = ibank;
}
if(SelectBank[ibank].x2>maxx)
{
maxx = SelectBank[ibank].x2;
thisbank = ibank;
}
/* 2nd: right -- the max x */
}
return(thisbank);
case 3: break; /* it is too easy, random choose */
case 4: for(ibank=0;ibank<BankCounter;ibank++)
{
ttype = SelectBank[ibank].type;
if(ttype==7||ttype==8||ttype==11||ttype==12) return(ibank);
/* 1st: right or left link type */
}
for(ibank=0;ibank<BankCounter;ibank++)
{
ttype = SelectBank[ibank].type;
if(ttype==14||ttype==15) return(ibank);
/* 2nd: opposite of right and left */
}
break;
case 5: for(ibank=0;ibank<BankCounter;ibank++)
{
ttype = SelectBank[ibank].type;
if(ttype==9||ttype==10) return(ibank);
/* 1st: up or down link type */
}
for(ibank=0;ibank<BankCounter;ibank++)
{
ttype = SelectBank[ibank].type;
if(ttype==7||ttype==8||ttype==11||ttype==12) return(ibank);
/* 2nd: right or left link type */
}
break;
case 6: for(ibank=0;ibank<BankCounter;ibank++)
{
ttype = SelectBank[ibank].type;
if(ttype==7||ttype==8||ttype==11||ttype==12) return(ibank);
/* 1st: right or left link type */
}
for(ibank=0;ibank<BankCounter;ibank++)
{
ttype = SelectBank[ibank].type;
if(ttype==9||ttype==10) return(ibank);
/* 1st: up or down link type */
}
break;
default: break;
}
ibank = random(BankCounter); /* 0 - Bank.Counter-1 */
return(ibank);
}
/* ------ The MAX file size in TC2.0 is 64607 ----------- */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -