一个用C++编写的五子棋游戏

一个用C++编写的五子棋游戏,第1张

一个用C++编写的五子棋游戏,第2张

////////////////////////////////
//
//Main。CPP by Yuheng Zhao
//
////////////////////////[br/]# include " types . h "
# include " mouse . h "
# include " shell . h "
int main(void)
{
init mouse();
init graphics();
draw background();
设定点(1,1);//我喜欢木森p?庞克腾1,1。
show point();
BOOL bWantToExit = FALSE;
c player player 1(1);
CP layer player 2(2);
player2。change player(TRUE);
CBoard板(&player1,& player 2);
int winner =-1;
int nCode =-1;
int x,y,b =-1;
c button Player 1 button(CRect(480,50,610,70)," Player 1 ");
c button player 2 button(CRect(480,75,610,95),“电脑”);
c button New button(CRect(450,430,530,450)," New ");
c button Quit button(CRect(540,430,620,450)," Quit ");
板。draw();
新建按钮。draw();
退出按钮。draw();
player 1按钮。draw();
player 2按钮。draw();
消息(" Luffar Schack!0.99");
消息(“作者”);
消息("宇恒赵1997-5 ");
消息("-");
消息("新游戏...");
while(!bWantToExit)
{
read mouse(x,y,b);
if(b = = 1)
{
if(quit button。Clicked(x,y,b))
{
Message("Exit ... ");
player2。change player(FALSE);
bWantToExit = TRUE;
延迟(200);
}
if (newButton。点击了(x,y,b))
{
板。ResetBoard();
}
if (player1Button。Clicked(x,y,b))

if (player2Button。Clicked(x,y,b))
{
if (player2。is computer())
{
player 2。change player(FALSE);
player 2按钮。SetWindowText("播放器2 ");
}其他
{
播放器2。change player(TRUE);
player 2按钮。SetWindowText("计算机");
};
延迟(200);
}
b =-1;
}
赢家=棋盘。go();
if(winner = = 1 | | winner = = 2)
{
Message((winner = = 1)?"一号玩家赢了。":
(player2。IsComputer())?“电脑赢”:“玩家2赢”);
nCode=(winner==1)?show windlg(& player 1):show windlg(& player 2);
if (nCode==1)
board。ResetBoard();
}
}
HidePoint();
closegraph();
返回0;
}
-

位律师回复
DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
白度搜_经验知识百科全书 » 一个用C++编写的五子棋游戏

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情