Game Development Reference
In-Depth Information
The Editor Is an Extension of the Game
As you review the code for the application, logic, and view layers, you
ll notice
that their classes look very similar to their Teapot Wars counterparts. When
writing a real editor, you
'
ll want your level editor to use the same engine
that runs your game. In our case, the classes look like simplified versions of
their Teapot Wars counterparts to make it easier to explain how the level
editor works.
'
The Application Layer
The level editor
'
s application layer is a very simple extension of the GameCodeApp
class.
class EditorApp : public GameCodeApp
{
public:
EditorApp() : GameCodeApp() { m_bIsEditorRunning = true; }
TCHAR *VGetGameTitle()
{ return _T(
GameCode4 Editor
); }
TCHAR *VGetGameAppDirectory()
{ return _T(
Game Coding Complete 4\\Editor\\1.0
); }
HICON VGetIcon()
{ return LoadIcon(GetInstance(), MAKEINTRESOURCE(IDI_ICON1));
protected:
BaseGameLogic *VCreateGameAndView();
};
BaseGameLogic* EditorApp::VCreateGameAndView()
{
BaseGameLogic *game = GCC_NEW EditorLogic();
game->VInit();
shared_ptr<IGameView> gameView(GCC_NEW EditorHumanView(g_pApp->m_Renderer));
game->VAddView(gameView);
return game;
}
This should be pretty familiar, because you looked at code like this in Chapter 5,
This code creates an instance of the game
logic class, EditorLogic , which will inherit from BaseGameLogic . It also creates
a view class, EditorHumanView .
Game Initialization and Shutdown.
 
 
Search WWH ::




Custom Search