Game Development Reference
In-Depth Information
The Event Manager is initialized next with these few lines of code:
m_pEventManager = GCC_NEW EventManager(
GameCodeApp Event Mgr
, true );
if (!m_pEventManager)
return false;
Initialize DirectX and Create Your Window
Windows programmers can
t put off the task of creating their window any longer.
Creating a game window is easy enough, especially since the DirectX Framework
does
'
'
the whole thing for you. Here
s
the code that does
this
job inside
InitInstance() :
DXUTInit( true, true, lpCmdLine, true );
DXUTCreateWindow( VGetGameTitle(), hInstance, VGetIcon());
if (!GetHwnd())
return FALSE;
SetWindowText(GetHwnd(), VGetGameTitle());
Notice the calls to the virtual methods VGetGameTitle() and VGetIcon() . They
are overloaded to provide this game-specific information to the GameCodeApp base
class. You
'
ll see exactly how to do this in Chapter 21,
A Game of Teapot Wars,
when we create a game of Teapot Wars with this code.
Since this code is using the DirectX Framework, the next line of code creates the
Direct3D device:
DXUTCreateDevice( D3D_FEATURE_LEVEL_10_1, true, screenWidth, screenHeight);
The constant, D3D_FEATURE_LEVEL_10_1 , will be discussed more in the 3D chap-
ters, but basically it sets the minimum 3D feature level required by your game.
Create Your Game Logic and Game View
After the game window is ready, you can create the game logic and all the views that
attach to the game logic. This is done by calling VCreateGameAndView() , which is
a pure virtual function in the GameCodeApp class. Here
'
s an example of what it
might look like in the inherited class:
BaseGameLogic *TeapotWarsApp::VCreateGameAndView()
{
BaseGameLogic *game = GCC_NEW TeapotWarsLogic();
shared_ptr<IGameView> gameView(GCC_NEW TeapotWarsHumanView());
game->VAddView(gameView);
return game;
}
 
 
 
Search WWH ::




Custom Search