091-越界检测
int CheckLeftBorder(chess_data Chess)
{
int x,y;
for(x=0;x<=3;x++)
for(y=0;y<=3;y++)
{
if (Ches091-越界检测
int CheckLeftBorder(chess_data Chess)
{
int x,y;
for(x=0;x<=3;x++)
for(y=0;y<=3;y++)
{
if ([x][y]) //判断棋子xy是不是为
{
if (+x<=CHESS_X+2)
{
return 1;
}
}
}
return 0;
}
/检测左边界是否到达,到达则返回否则为
//棋子坐标小于等棋盘左上角坐标
int CheckRightBorder(chess_data Chess)
{
int x,y;
for(x=0;x>=0;x--)
for(y=0;y>=0;y--)
{
if ([x][y]) //判断棋子xy是不是为
{
if (+x>=CHESS_X+CHESS_WIDTH-4)
{
return 1;
}
}
}
return 0;
}
//检测右边界
//左边界│占2字符宽度+右边界│占的2个字符宽度所以得减4
int CheckDownBorder(chess_data Chess)
{
int x,y;
for(y=0;y<=3;y++)
for(x=0;x<=3;x++)
{
if ([x][y]) //判断棋子xy是不是为
{
if (+y+1>=CHESS_Y+CHESS_HIGHT)
{
return 1;
}
}
}
return 0;
//检测下边界
//棋子坐标小于等棋盘左上角坐标
void playgame(void)
{
int ch=0;//读取键盘光标
chess_data oneChess;
InitChessData();//20种形状的函数
oneChess=DownChessData[0][0];
ShowChess(oneChess);
//开始游戏
091-越界检测
//光标控制游戏
while(1)
{
ch=getch(); //读取键盘光标存储到变量ch
gotoxy(35,30);
switch(ch)
{
default:
printf(
091-越界检测 来自淘豆网m.daumloan.com转载请标明出处.