資源簡介
大富翁 C++ 游戲編程 對于許多剛剛入門C++的同學來說很有幫助的,可以參考一下

代碼片段和文件信息
#include?“dxcls.h“
/*
Defination?for?DDraw
*/
CDDraw::CDDraw(HWND?hWndinDWORD?dwWidthDWORD?dwHeightDWORD?dwColor)
{
m_hwnd=hWndin;
m_lpdd=NULL;
if(FAILED(DirectDrawCreateEx(NULL(LPVOID*)&m_lpddIID_IDirectDraw7NULL)))
{
m_bActive=false;
InitError(“DirectDraw?Init?Failed!\n“);
}
if(FAILED(m_lpdd->SetCooperativeLevel(m_hwndDDSCL_EXCLUSIVE|DDSCL_FULLSCREEN)))
{
m_bActive=false;
InitError(“DirectDraw?SetCooperative?Level?Failed!\n“);
}
if(FAILED(m_lpdd->SetDisplayMode(dwWidthdwHeightdwColor
0DDSDM_STANDARDVGAMODE)))
{
m_bActive=false;
InitError(“DirectDraw?Set?Display?Mode?Failed!\n“);
}
m_bActive=true;
#ifdef?_DXDEBUG
DebugOut(“DirectDraw?Initialized!\n“);
#endif
}
CDDraw::~CDDraw()
{
if(m_bActive!=false)
{
m_lpdd->Release();
}
#ifdef?_DXDEBUG
DebugOut(“DirectDraw?Released!\n“);
#endif
}
void?CDDraw::InitError(char?szErr[])
{
MessageBox(m_hwndszErr“DirectX?Error“MB_OK);
#ifdef?_DXDEBUG
DebugOut(szErr);
#endif
SendMessage(m_hwndWM_DESTROYNULLNULL);
}
void?CDDraw::SetDispMode(DWORD?dwWidthDWORD?dwHeightDWORD?dwColor)
{
if(FAILED(m_lpdd->SetDisplayMode(dwWidthdwHeight
dwColor0DDSDM_STANDARDVGAMODE)))
{
InitError(“DirectDraw?Set?Display?Mode?Failed!\n“);
}
}
void?CDDraw::SetDispMode(int?flag)
{
DWORD?dwWidthdwHeightdwColor;
switch(flag)
{
case?HIGH_RES:
dwWidth=HI_WID;
dwHeight=HI_HEI;
dwColor=HI_COL;
break;
case?MED_RES:
dwWidth=ME_WID;
dwHeight=ME_HEI;
dwColor=ME_COL;
break;
case?LOW_RES:
dwWidth=LO_WID;
dwHeight=LO_HEI;
dwColor=LO_COL;
break;
}
if(FAILED(m_lpdd->SetDisplayMode(dwWidthdwHeight
dwColor0DDSDM_STANDARDVGAMODE)))
{
InitError(“DirectDraw?Set?Display?Mode?Failed!\n“);
}
}
/*
End?of?the?DDraw?Block
*/
//////////////////////////////////////////////////////////////////////////////////////
/*
Defination?for?base?Surface?class
*/
LPDIRECTDRAWSURFACE7?CDDSurf::GetSurfHandle()?const
{
if(m_bActive!=false)
{
return?m_lpdds;
}
else
{
return?NULL;
}
}
void?CDDSurf::LoadBMP(char?szName[])
{
HBITMAP?hbm;
HDC?hdcImage=NULL;
HDC?hdcSurf=NULL;
if(m_bActive==false)?{InitError(“Surface?Not?Inittialized!“);?return;}
hbm=(HBITMAP)LoadImage(NULLszNameIMAGE_BITMAP
m_ddsd.dwWidthm_ddsd.dwHeight
???????????????????LR_LOADFROMFILE|LR_CREATEDIBSECTION);
if(hbm==NULL)
{
Deleteobject(hbm);
InitError(“Load?Bitmap?Error!\n“);
return;
}
hdcImage=CreateCompatibleDC(NULL);
Selectobject(hdcImagehbm);
if(FAILED(m_lpdds->GetDC(&hdcSurf)))
{
DeleteDC(hdcImage);
Deleteobject(hbm);
InitError(“GetSurface?DC?Failed!\n“);
return;
}
if(FAILED(BitBlt(hdcSurf00m_ddsd.dwWidth
??m_ddsd.dwHeighthdcImage00SRCCOPY)))
{
DeleteDC(hdcImage);
m_lpdds->ReleaseDC(hdcSurf);
Deleteobject(hbm);
InitError(“Bit?Blt?Failed!\n“);
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????28??2003-05-08?16:56??大富翁\back.int
?????文件?????????31??2003-05-13?01:37??大富翁\board.int
?????文件?????????36??2003-05-11?15:53??大富翁\box.int
?????文件?????????19??2003-05-12?05:55??大富翁\button1.int
?????文件?????????19??2003-05-12?05:56??大富翁\button2.int
?????文件?????????21??2003-05-19?13:23??大富翁\button3.int
?????文件?????????19??2003-05-21?12:52??大富翁\button4.int
?????文件??????????3??2003-05-21?13:39??大富翁\card.txt
?????文件?????????10??2003-05-09?01:15??大富翁\ddraw.int
?????文件?????483770??2008-03-15?20:52??大富翁\Debug.txt
?????文件????????327??2003-05-13?02:17??大富翁\def.h
?????文件???????4400??2003-05-17?22:27??大富翁\DirectX?Test.dsp
?????文件????????549??2003-05-09?17:45??大富翁\DirectX?Test.dsw
?????文件?????647226??2006-12-21?17:55??大富翁\DirectX?Test.exe
?????文件?????238592??2003-07-07?12:53??大富翁\DirectX?Test.ncb
?????文件??????53760??2003-07-07?12:53??大富翁\DirectX?Test.opt
?????文件???????1348??2003-05-24?19:17??大富翁\DirectX?Test.plg
?????文件??????11554??2003-05-19?12:02??大富翁\dxcls.cpp
?????文件???????9373??2003-05-13?02:51??大富翁\dxcls.h
?????文件?????????30??2003-05-12?06:21??大富翁\fr
?????文件????????295??2003-05-16?08:44??大富翁\map.int
?????文件????????398??2003-05-24?13:41??大富翁\market.int
?????文件?????????28??2003-05-13?09:21??大富翁\mini.int
?????文件???????1438??2003-05-11?21:30??大富翁\mouse.bmp
?????文件????????188??2003-05-21?12:52??大富翁\panel.int
?????文件?????????33??2003-05-12?10:33??大富翁\pclip.int
?????文件?????????36??2003-05-23?15:29??大富翁\pla
?????文件?????????34??2003-05-23?15:29??大富翁\pla
?????文件?????????32??2003-05-12?13:19??大富翁\pla
?????文件???????6264??2003-05-23?10:43??大富翁\position.txt
............此處省略59個文件信息
- 上一篇:數據結構C++殷人昆第二版答案
- 下一篇:C語言寫的音樂播放器(含源碼注釋)
評論
共有 條評論