资源简介

大学时期(2010年)的学习作品。基于windows + DirectX3D开发的简单游戏框架。

资源截图

代码片段和文件信息

//D3DApp.cpp
#include “../include/Commen.h“
#include “D3DApp.h“
#include “Game.h“

CD3DApp g_gameApp;//游戏类应用程序对象
///////////////////主函数///////////////////////////////////
int WINAPI WinMain( HINSTANCE hInstanceHINSTANCELPSTRint)
{

if(g_gameApp.init(hInstanceL“D3DApp“800600))//初始化游戏类
{
g_gameApp.mainLoop();//游戏循环
}
return 0;
}
///////////////////class CD3DApp start/////////////////////////
CD3DApp::CD3DApp()
{
m_pGame=NULL;
m_hWnd=NULL;
m_hInstance=NULL;
m_pd3dDevice=NULL;
m_bFullScreen=false;
m_width=640;
m_height=480;
m_bGameStart=false;
wcscpy_s(m_szCaptionL“无标题“);
}
CD3DApp::~CD3DApp()
{
m_pGame->destroy();
SafeDelete(m_pGame);
SafeRelease(m_pd3dDevice);
UnregisterClass(L“GameEngin“m_hInstance);
}

/* 游戏类初始化
** hInstance: 应用程序实例对象
** caption: 窗口标题
** width: 窗口宽度
** height: 窗口高度
** bFullScreen: 是否全屏
*/
bool CD3DApp::init(HINSTANCE hInstance
   WCHAR *caption
   int width
   int height
   bool bFullScreen)
{
m_pGame=new CGame();
m_hInstance=hInstance;
m_width=width;
m_height=height;
m_bFullScreen=bFullScreen;
if(caption != NULL)
{
wcscpy_s(m_szCaptioncaption);
}
registerClass();//注册窗口类
if(!createWindow())//创建窗口
{
return false;
}
if(!initD3D())//初始化Direct3D对象及设备
{
return false;
}
if(!m_pGame->initGame(m_pd3dDevicem_hWndm_hInstance))//初始化其他
{
return false;
}
if (!initGUI())
{
return false;
}
ShowWindow(m_hWndSW_SHOW);
UpdateWindow(m_hWnd);
return true;
}
//初始化Direct3D对象及设备对象
bool CD3DApp::initD3D()
{
IDirect3D9 *pD3D=Direct3DCreate9(D3D_SDK_VERSION);
if(NULL == pD3D)
{
return false;
}
//获得显卡当前显示模式
D3DDISPLAYMODE d3dmm;
pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT&d3dmm);
//设置显示参数
D3DPRESENT_PARAMETERS d3dpp;
memset(&d3dpp0sizeof(d3dpp));
d3dpp.Windowed=!m_bFullScreen;
d3dpp.SwapEffect=D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat=d3dmm.Format;
d3dpp.EnableAutoDepthStencil=TRUE;
d3dpp.AutoDepthStencilFormat=D3DFMT_D16;
if(m_bFullScreen)
{//全屏显示
d3dpp.BackBufferHeight=d3dmm.Height;
d3dpp.BackBufferWidth=d3dmm.Width;
d3dpp.FullScreen_RefreshRateInHz=d3dmm.RefreshRate;
d3dpp.PresentationInterval=D3DPRESENT_INTERVAL_ONE;
}
//创建Direct3D设备对象
if(FAILED(pD3D->CreateDevice(
D3DADAPTER_DEFAULT
D3DDEVTYPE_HAL
m_hWnd
D3DCREATE_SOFTWARE_VERTEXPROCESSING
&d3dpp
&m_pd3dDevice)))
{
SafeRelease(pD3D);
return false;
}
SafeRelease(pD3D);

m_pd3dDevice->SetRenderState(D3DRS_CULLMODED3DCULL_NONE);
m_pd3dDevice->SetRenderState(D3DRS_ZENABLETRUE);

//设置部分环境光
m_pd3dDevice->SetRenderState(D3DRS_AMBIENTD3DCOLOR_XRGB(100100100));
return true;
}
//注册窗口类
void CD3DApp::registerClass()
{
WNDCLASSEX wc;
memset(&wc0sizeof(wc));
wc.cbSize=sizeof(wc);
wc.lpfnWndProc=(WNDPROC)windowProc;
wc.hInstance=m_hInstance;
wc.lpszClassName=L“GameEngin“;
wc.hbrBackground=(HBRUSH)GetStockobject(BLACK

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      59048  2011-08-02 22:40  D3DEngine\3DPushBox\3DPushBox.aps

     文件       1690  2011-08-02 22:40  D3DEngine\3DPushBox\3DPushBox.rc

     文件       2573  2011-09-13 20:05  D3DEngine\3DPushBox\3DPushBox.sln

    ..A..H.     31232  2011-09-13 20:37  D3DEngine\3DPushBox\3DPushBox.suo

     文件       4718  2011-09-13 20:00  D3DEngine\3DPushBox\3DPushBox.vcproj

     文件       1427  2011-08-09 13:24  D3DEngine\3DPushBox\3DPushBox.vcproj.S5I0CGI2FZ4EPQA.Administrator.user

     文件       1411  2011-09-13 20:37  D3DEngine\3DPushBox\3DPushBox.vcproj.ZHOUBAO.Administrator.user

     文件    1408512  2011-08-20 16:42  D3DEngine\3DPushBox\3D推箱子.exe

     文件       7671  2011-08-02 21:19  D3DEngine\3DPushBox\D3DApp.cpp

     文件       1626  2011-08-02 21:20  D3DEngine\3DPushBox\D3DApp.h

     文件      25214  2011-08-02 22:41  D3DEngine\3DPushBox\directx.ico

     文件       7982  2011-08-29 11:07  D3DEngine\3DPushBox\DxSound.cpp

     文件       1146  2011-08-29 10:53  D3DEngine\3DPushBox\DxSound.h

     文件      17004  2011-09-13 19:58  D3DEngine\3DPushBox\Game.cpp

     文件       2213  2011-09-13 20:34  D3DEngine\3DPushBox\Game.h

     文件          3  2011-08-09 10:27  D3DEngine\3DPushBox\level\level.ini

     文件         62  2011-08-08 21:18  D3DEngine\3DPushBox\level\level1.map

     文件        124  2011-08-09 10:08  D3DEngine\3DPushBox\level\level2.map

     文件        138  2011-08-09 10:27  D3DEngine\3DPushBox\level\level3.map

     文件        406  2011-08-08 21:13  D3DEngine\3DPushBox\level\地图数据说明.txt

     文件         87  2011-09-13 20:36  D3DEngine\3DPushBox\log.txt

     文件       1595  2011-08-05 17:59  D3DEngine\3DPushBox\Player.cpp

     文件        448  2011-08-05 17:56  D3DEngine\3DPushBox\Player.h

     文件       1825  2011-08-02 16:44  D3DEngine\3DPushBox\PushBoxCube.cpp

     文件        553  2011-08-02 19:44  D3DEngine\3DPushBox\PushBoxCube.h

     文件       6831  2011-08-08 20:55  D3DEngine\3DPushBox\PushBoxMap.cpp

     文件       1695  2011-08-08 14:26  D3DEngine\3DPushBox\PushBoxMap.h

     文件        452  2011-08-02 22:40  D3DEngine\3DPushBox\resource.h

     文件      74297  1999-12-07 21:22  D3DEngine\3DPushBox\sound\background.mid

     文件      13538  2002-01-06 13:10  D3DEngine\3DPushBox\sound\get.wav

............此处省略321个文件信息

评论

共有 条评论