Game Development Reference
In-Depth Information
m_pPhysics.reset(CreateNullPhysics());
}
The constructor initializes the
m_ProjectDirectory
member with the assumption
that the current working directory is where the final game asset files are built. This is
pretty common even among commercial editors. Assuming a little bit about a valid
directory structure can actually save a ton of headaches down the road, especially
considering where your raw game assets are stored. The physics system is initialized
with a NULL physics stub. The NULL physics class implements all of the pure virtual
functions of the
IGamePhysics
interface with empty stubs.
bool EditorLogic::VLoadGame(const char* levelName)
{
while (m_actors.size() > 0)
{
ActorId id = m_actors.begin()->first;
VDestroyActor(id);
}
if (!BaseGameLogic::VLoadGame(levelName))
{
return false;
}
VChangeState(BGS_Running);
return true;
}
shared_ptr<EditorHumanView> EditorLogic::GetHumanView()
{
GCC_ASSERT(m_gameViews.size()==1);
shared_ptr<IGameView> pGameView = *m_gameViews.begin();
shared_ptr<EditorHumanView> editorHumanView =
static_pointer_cast<EditorHumanView>( pGameView );
return editorHumanView;
}
VLoadGame()
simply destroys all the existing actors before calling the overloaded
method of
BaseGameLogic
.
GetHumanView()
returns a pointer to the view that cre-
ates a rendered image of the contents of the game universe. Since we don
'
thaveanyAIs
or extra players, we
'
ll only have one view for the editor, which simplifies things greatly.
The classes for the editor view are very similar to their Teapot Wars counterparts.