最简单的迷宫.ppt
《最简单的迷宫.ppt》由会员分享,可在线阅读,更多相关《最简单的迷宫.ppt(32页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、最简单的迷宫程序的效果Corridor.xRoom.x步骤搭建基本框架创建Win32项目删除不必要的代码,只保留_tWinMain()包含框架文件创建自己的应用程序类添加cApp类,并修改WinMain中的代码。按照设计,添加网格对象和三维对象添加其他成员变量完成Init实现初始化的操作完成Frame实现对每一帧的操作完成Shutdown实现退出时的清理工作1.1 创建Win32项目添加对应的库文件d3d9.lib d3dx9.lib d3dxof.lib dxguid.lib dinput8.lib winmm.lib1.2 删除不必要的代码1.3 包含框架文件(1)1.3 包含框架文件(2
2、)1.3 包含框架文件(3)有什么作用?有什么作用?1.3 包含框架文件(4)2.1 创建自己的应用程序类(1)2.1 修改WinMain函数(2)添加网格和三维对象cMesh表示网格对象cObject表示三维对象cMesh m_RoomMeshes2;/两个网格cObject m_RoomObjects8;/八个对象添加其他成员变量cGraphics m_Graphics;/Graphics objectcCamera m_Camera;/CameracInputm_Input;/Input objectcInputDevice m_Keyboard;/Keyboard device obj
3、ectcInputDevice m_Mouse;/Moues device objectfloat m_XPos,m_ZPos;/Viewpoint position完成构造函数cApp:cApp()cApp:cApp(void)m_Width =640;m_Height=480;m_Style =WS_BORDER|WS_CAPTION|WS_MINIMIZEBOX|WS_SYSMENU;strcpy(m_Class,MeshLvlClass);strcpy(m_Caption,MeshLvl Demo by CCNIIT);覆盖cApplication中的关键函数bool Init()bo
4、ol Frame()bool Shutdown()Init()初始化Frame()帧计算Shutdown()清理在Init中进行初始化的操作/Initialize the graphics device and set display modem_Graphics.Init();m_Graphics.SetMode(GethWnd(),TRUE,TRUE);m_Graphics.SetPerspective(D3DX_PI/4,1.3333f,1.0f,10000.0f);ShowMouse(TRUE);/Initialize input and input devicesm_Input.In
5、it(GethWnd(),GethInst();m_Keyboard.Create(&m_Input,KEYBOARD);m_Mouse.Create(&m_Input,MOUSE,TRUE);加载网格模型/Load the room meshesm_RoomMeshes0.Load(&m_Graphics,.DataCorridor.x,.Data);m_RoomMeshes1.Load(&m_Graphics,.DataRoom.x,.Data);创建三维物体/Setup the room objectsm_RoomObjects0.Create(&m_Graphics,&m_RoomMe
6、shes1);/房间m_RoomObjects1.Create(&m_Graphics,&m_RoomMeshes0);/走廊m_RoomObjects2.Create(&m_Graphics,&m_RoomMeshes1);m_RoomObjects3.Create(&m_Graphics,&m_RoomMeshes0);m_RoomObjects4.Create(&m_Graphics,&m_RoomMeshes0);m_RoomObjects5.Create(&m_Graphics,&m_RoomMeshes1);m_RoomObjects6.Create(&m_Graphics,&m_
7、RoomMeshes0);m_RoomObjects7.Create(&m_Graphics,&m_RoomMeshes1);放好位置/Move room objects into positionm_RoomObjects0.Move(-2000.0f,0.0f,2000.0f);m_RoomObjects1.Move(0.0f,0.0f,2000.0f);m_RoomObjects2.Move(2000.0f,0.0f,2000.0f);m_RoomObjects3.Move(-2000.0f,0.0f,0.0f);m_RoomObjects4.Move(2000.0f,0.0f,0.0f
8、);m_RoomObjects5.Move(-2000.0f,0.0f,-2000.0f);m_RoomObjects6.Move(0.0f,0.0f,-2000.0f);m_RoomObjects7.Move(2000.0f,0.0f,-2000.0f);ZX/Move room objects into positionm_RoomObjects0.Move(-2000.0f,0.0f,2000.0f);m_RoomObjects1.Move(0.0f,0.0f,2000.0f);m_RoomObjects2.Move(2000.0f,0.0f,2000.0f);m_RoomObjects
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 简单 迷宫
限制150内