剑三凤翼云箫曲子:这段程序怎么解释?

来源:百度文库 编辑:中科新闻网 时间:2024/04/30 04:10:46
void DoWin(int Order)
{
sound(1500);delay(100);
sound(0); delay(50);
sound(800); delay(100);
sound(0); delay(50);
sound(1500);delay(100);
sound(0); delay(50);
sound(800); delay(100);
sound(0); delay(50);
nosound();

textcolor(RED+BLINK);
gotoxy(25,20);
if(Order==CHESS1)
cputs("PLAYER1 WIN!");
else
cputs("PLAYER2 WIN!");
gotoxy(25,21);
cputs(" \\<^+^>/");
getch();
}

int JudgeWin(int Order,struct point Cursor)
{
int i;
for(i=0;i<4;i++)
if(JudgeWinLine(Order,Cursor,i))
return TRUE;
return FALSE;
}

int JudgeWinLine(int Order,struct point Cursor,int direction)
{
int i;
struct point pos,dpos;
const int testnum = 5;
int count;

switch(direction)
{
case 0:
pos.x=Cursor.x-(testnum-1);
pos.y=Cursor.y;
dpos.x=1;
dpos.y=0;
break;
case 1:
pos.x=Cursor.x;
pos.y=Cursor.y-(testnum-1);
dpos.x=0;
dpos.y=1;
break;
case 2:
pos.x=Cursor.x-(testnum-1);
pos.y=Cursor.y+(testnum-1);
dpos.x=1;
dpos.y=-1;
break;
case 3:
pos.x=Cursor.x-(testnum-1);
pos.y=Cursor.y-(testnum-1);
dpos.x=1;
dpos.y=1;
break;
}

count=0;
for(i=0;i<testnum*2+1;i++)
{
if(pos.x>=0&&pos.x<=18&&pos.y>=0&&pos.y<=18)
{
if(gChessBoard[pos.x][pos.y]==Order)
{
count++;
if(count>=testnum)
return TRUE;
}
else
count=0;
}
pos.x+=dpos.x;
pos.y+=dpos.y;
}

return FALSE

是个游戏代码
DoWin()用来发声,不过参变量order没用着
textcolor(RED+BLINK),调用textcolor(),red+blink是个值,作参数,等效于
y=red+blink
textcolor(y)

其它的自已分析
自已分析才能学到东东