資源簡介
斗地主是一個很流行的游戲,如何編程實現它,這里提供一個難得的有趣的學習C++的實例!

代碼片段和文件信息
//?Client_Game.cpp:?implementation?of?the?CClientGame?class.
//
//////////////////////////////////////////////////////////////////////
#include?“stdafx.h“
#include?“斗地主.h“
#include?“Game.h“
#include?“link.h“
#include?“My_DirectInput.h“
#include?“my_directdraw.h“
#include?“Playing_Cards.h“
#include?“Draw_Item_Engine.h“
#include?“Draw_Cards_Engine.h“
#include?“Client_Game.h“
#ifdef?_DEBUG
#undef?THIS_FILE
static?char?THIS_FILE[]=__FILE__;
#define?new?DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
//?Construction/Destruction
//////////////////////////////////////////////////////////////////////
CClientGame::CClientGame()
{
}
CClientGame::~CClientGame()
{
}
//左邊玩家(電腦)思考,并決定要出的牌;
int?CClientGame::LeftDoing()
{
if(?m_nLordLock?==?0?)
{
if(?m_nRoundCounter?==?3?)??//說明已經出了牌;
{
//把已經出的牌回退;
if(pLeftCards->m_nDiscardingCounter?!=?0)
pDrawCards->LeftBacking();
if(pCenterCards->m_nDiscardingCounter?!=?0)
pDrawCards->CenterBacking();
if(pRightCards->m_nDiscardingCounter?!=?0)
pDrawCards->RightBacking();
m_nRoundCounter?=?0;???//新的一圈;
}
m_nRoundCounter++;
return?-1;
}
if(?pRightCards->m_cDiscardingType.m_nTypeNum?==?0?&&?
pCenterCards->m_cDiscardingType.m_nTypeNum?==?0?)
{
m_nLordLock?=?-1;
}
//補丁調整出牌顯示;
int?Temp_Discarding_Counter?=?0;??//剛出的牌的數量;
CCard?Temp_Discarding[20];?????????//剛出的牌;
pClientlink->Recv(Temp_Discardingsizeof(CCard)*20);
pClientlink->Recv(&Temp_Discarding_Countersizeof(int));
pClientlink->Recv(&pLeftCards->m_cDiscardingTypesizeof(CCardsType));
if(?m_nRoundCounter?==?3?)??//說明已經出了牌;
{
//把已經出的牌回退;
if(pLeftCards->m_nDiscardingCounter?!=?0)
pDrawCards->LeftBacking();
if(pCenterCards->m_nDiscardingCounter?!=?0)
pDrawCards->CenterBacking();
if(pRightCards->m_nDiscardingCounter?!=?0)
pDrawCards->RightBacking();
m_nRoundCounter?=?0;???//新的一圈;
}
m_nRoundCounter++;
for(int?i=0;i<20;i++)
{
pLeftCards->m_cDiscarding[i]?=?Temp_Discarding[i];
}
pLeftCards->m_nDiscardingCounter?=?Temp_Discarding_Counter;
//如果出牌數大于0;
if(?pLeftCards->m_cDiscardingType.m_nTypeNum?==?4?)
{
m_nBombCounter++;//加分;
}
if(?pLeftCards->m_cDiscardingType.m_nTypeNum?!=?0?)
{
pDrawCards->LeftDiscarding();
::RedrawGame();
if(?pLeftCards->m_nCardsCounter?==?0?)
{
//打印結束信息;
AccountScore(0);
::SetTimer(hWnd00NULL);???//開始游戲;
return?0;
}
}
else
{
//打印左邊玩家不要信息;
pDraw->TextGDI(“過牌!-“250200RGB(25500)400“華文新魏“lpddsprimary);
if(?m_nCurrentLord?==?0?)
{
m_nLordLock?=?0;
}
Sleep(300);
}
return?1;
}
//中間(本機)玩家出牌;
int?CClientGame::CenterDoing()
{
if(?m_nLordLock?==?1?)
{
if(?m_nRoundCounter?==?3?)??//說明已經出了牌;
{
//把已經出的牌回退;
if(pCenterCards->m_nDiscardingCounter?!=?0)
pDrawCards->CenterBacking();
if(pRightCards->m_nDiscardin
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2004-06-02?15:47??斗地主\
?????目錄???????????0??2004-06-10?23:41??斗地主\bmp\
?????目錄???????????0??2004-06-10?23:41??斗地主\bmp\cards\
?????文件??????112232??2004-04-17?23:04??斗地主\bmp\cards\10.bmp
?????文件??????112232??2004-04-17?23:02??斗地主\bmp\cards\2.bmp
?????文件??????112232??2004-04-17?23:05??斗地主\bmp\cards\3.bmp
?????文件??????112232??2004-04-17?23:21??斗地主\bmp\cards\4.bmp
?????文件??????112232??2004-04-17?23:24??斗地主\bmp\cards\5.bmp
?????文件??????112232??2004-04-17?23:19??斗地主\bmp\cards\6.bmp
?????文件??????112232??2004-04-17?23:34??斗地主\bmp\cards\7.bmp
?????文件??????112232??2004-04-17?23:28??斗地主\bmp\cards\8.bmp
?????文件??????112232??2004-04-17?23:31??斗地主\bmp\cards\9.bmp
?????文件??????112232??2004-04-17?23:03??斗地主\bmp\cards\A.bmp
?????文件???????28328??2004-06-10?15:06??斗地主\bmp\cards\card_back1.bmp
?????文件??????112232??2004-04-21?18:02??斗地主\bmp\cards\J.bmp
?????文件???????56144??2004-04-22?11:35??斗地主\bmp\cards\Jokers.bmp
?????文件??????112232??2004-04-21?17:54??斗地主\bmp\cards\K.bmp
?????文件??????112232??2004-04-17?23:08??斗地主\bmp\cards\Q.bmp
?????文件??????111104??2004-06-10?20:31??斗地主\bmp\cards\Thumbs.db
?????目錄???????????0??2004-06-10?23:41??斗地主\bmp\faces\
?????文件???????14896??2004-05-08?19:24??斗地主\bmp\faces\face0.bmp
?????文件???????14896??2004-05-08?20:18??斗地主\bmp\faces\face1.bmp
?????文件???????14896??2004-05-08?20:18??斗地主\bmp\faces\face2.bmp
?????文件???????14896??2004-05-08?20:18??斗地主\bmp\faces\face3.bmp
?????文件???????24576??2004-05-09?01:27??斗地主\bmp\faces\Thumbs.db
?????文件?????3145784??2004-06-10?23:37??斗地主\bmp\Game_Back.bmp
?????目錄???????????0??2004-06-10?23:41??斗地主\bmp\item\
?????文件??????135056??2004-05-14?19:42??斗地主\bmp\item\bring_lord.bmp
?????文件???????48056??2004-05-16?17:11??斗地主\bmp\item\choose_lord.bmp
?????文件???????17384??2004-05-14?19:47??斗地主\bmp\item\lord_fr
?????文件????????7256??2004-05-15?02:16??斗地主\bmp\item\Ok_Button.bmp
............此處省略75個文件信息
評論
共有 條評論