赛车游戏源码


有开发详细说明文档和PPT,当然包括源代码
资源截图
代码片段和文件信息
// CHECK MARKER


/**************************************************
Core_Graphics.cpp
GameCore Component

Programming Role-Playing Games with DirectX 2nd Edition
by Jim Adams (Jan 2004)
**************************************************/

#include “Core_Global.h“
#include “rmxftmpl.h“
#include “rmxfguid.h“
#include “dxutil.h“
//#include “myplus.h“




cGraphics::cGraphics()
{
  m_hWnd = NULL;
  
  m_pD3D = NULL;
  m_pD3DDevice = NULL;
  m_pSprite = NULL;
  m_AmbientRed = m_AmbientGreen = m_AmbientBlue = 255;

  m_Width  = 0;
  m_Height = 0;
  m_BPP    = 0;

  m_Windowed = TRUE;
  m_ZBuffer  = FALSE;
  m_HAL      = FALSE;
}

cGraphics::~cGraphics()
{
  Shutdown();
}

BOOL cGraphics::Init()
{
  Shutdown();

  if((m_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL)
    return FALSE;

  return TRUE;
}

BOOL cGraphics::SetMode(HWND hWnd BOOL Windowed BOOL UseZBuffer long Width long Height char BPP)
{
  D3DPRESENT_PARAMETERS d3dpp;
  D3DFORMAT             Format AltFormat;
  RECT                  WndRect ClientRect;
  long                  WndWidth WndHeight;
  float                 Aspect;

  // Error checking
  if((m_hWnd = hWnd) == NULL)
    return FALSE;
  if(m_pD3D == NULL)
    return FALSE;

  // Get the current display format
  if(FAILED(m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT &m_d3ddm)))
    return FALSE;

  // Configure width
  if(!Width) {
    // Default to screen width if fullscreen
    if(Windowed == FALSE) {
      m_Width = m_d3ddm.Width;
    } else {
      // Otherwise grab from client size
      GetClientRect(m_hWnd &ClientRect);
      m_Width = ClientRect.right;
    }
  } else {
    m_Width = Width;
  }

  // Configure height
  if(!Height) {
    // Default to screen height if fullscreen
    if(Windowed == FALSE) {
      m_Height = m_d3ddm.Height;
    } else {
      // Otherwise grab from client size
      GetClientRect(m_hWnd &ClientRect);
      m_Height = ClientRect.bottom;
    }
  } else {
    m_Height = Height;
  }

  // Configure BPP
  if(!(m_BPP = BPP) || Windowed == TRUE) {
    if(!(m_BPP = GetFormatBPP(m_d3ddm.Format)))
      return FALSE;
  }

  // Resize client window if using windowed mode
  if(Windowed == TRUE) {
    GetWindowRect(m_hWnd &WndRect);
    GetClientRect(m_hWnd &ClientRect);

    WndWidth  = (WndRect.right  - (ClientRect.right  - m_Width))  - WndRect.left;
    WndHeight = (WndRect.bottom - (ClientRect.bottom - m_Height)) - WndRect.top;

    MoveWindow(m_hWnd WndRect.left WndRect.top WndWidth WndHeight TRUE);
  }

  // Clear presentation structure
  ZeroMemory(&d3dpp sizeof(D3DPRESENT_PARAMETERS));
  
  // Default to no hardware acceleration detected
  m_HAL = FALSE;

  // Setup Windowed or fullscreen usage
  if((m_Windowed = Windowed) == TRUE) {
    d3dpp.Windowed         = TRUE;
    d3dpp.SwapEffect       = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-06-22 23:16  GameCore
     文件         763  2007-10-16 16:44  GameCoreCore_Global.h
     文件       74409  2008-05-26 11:40  GameCoreCore_Graphics.cpp
     文件       26898  2008-05-11 22:28  GameCoreCore_Graphics.h
     文件       12818  2007-10-16 16:44  GameCoreCore_Input.cpp
     文件        7772  2007-10-16 16:44  GameCoreCore_Input.h
     文件       24318  2007-10-16 16:44  GameCoreCore_Network.cpp
     文件        6563  2007-10-16 16:44  GameCoreCore_Network.h
     文件       31633  2008-05-19 16:55  GameCoreCore_Sound.cpp
     文件        6612  2008-05-19 16:59  GameCoreCore_Sound.h
     文件        8549  2008-02-17 22:02  GameCoreCore_System.cpp
     文件        2970  2008-05-18 21:23  GameCoreCore_System.h
     目录           0  2013-06-23 21:58  GameCoreDebug
     文件       12533  2008-02-17 16:46  GameCoreSPE.h
     文件        2298  2008-02-17 11:27  GameCoreSPEArray.h
     文件         748  2008-02-09 15:15  GameCoreSPEGeometry.h
     文件         537  2008-01-26 11:15  GameCoreSPELib.h
     文件        1885  2008-05-06 13:36  GameCoreSPEMesh.h
     文件        2176  2008-02-06 11:26  GameCoreSPEPhysics.h
     文件        4363  2008-05-11 13:09  GameCoreSPEUtil.h
     文件        9397  2008-01-31 17:30  GameCoreSPEVector_Matrix.h
     文件       37459  2007-05-10 20:26  GameCoredxutil.cpp
     文件        8243  2008-05-06 18:22  GameCoredxutil.h
     文件        3347  2008-05-06 18:21  GameCoremyplus.h
     文件         685  2008-05-16 22:09  GameCore
esource.h
     文件       75265  2008-05-10 00:08  GameCore复件 Core_Graphics.cpp
     文件         709  2008-05-20 17:48  Racecar.exe.lnk
     文件         699  2008-05-20 17:48  Server.exe.lnk
     文件        1000  2008-05-26 23:10  readme.txt
     文件      336384  2008-05-26 15:25  帮助文档.doc
     文件       56320  2008-05-26 16:48  开发文档.doc
............此处省略137个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)