Game Development Reference
In-Depth Information
The Editor
s Logic Class
The editor logic is pretty simple. Since this is a basic level editor, it doesn
'
t need
physics. In a level editor for a commercial game, a running physics system will ensure
legal placement of objects and make sure they settle properly. In the example below,
there is a physics system, but it is completely empty of code
'
a NULL physics sys-
tem. I ' ll leave implementing a real physics system in the editor to you as an exercise.
Any calls to the physics system will just end in stubs and not do anything at all.
The EditorLogic class will look familiar to you if you
'
ve looked over the Teapot-
WarsBaseLogic class in the previous chapter:
class EditorLogic : public BaseGameLogic
{
public:
EditorLogic();
~EditorLogic() { }
virtual bool VLoadGame(const char* levelName);
const std::string &GetProjectDirectory(void) { return m_ProjectDirectory; }
// We need to expose this information so that the C# app can
// know how big of an array to allocate to hold the list of
// actors
int GetNumActors() { return (int)m_actors.size(); }
// Exposes the actor map so that the global functions
// can retrieve actor information
const ActorMap& GetActorMap() { return m_actors; }
shared_ptr<EditorHumanView> GetHumanView();
protected:
std::string m_ProjectDirectory;
};
As you can see, most of the EditorLogic class is defined right in the constructor.
EditorLogic is a thin wrapper around BaseGameLogic , since all it has to do is pro-
vide some accessor methods to the actor lists and manage a view. Here
'
s the constructor:
EditorLogic::EditorLogic()
: BaseGameLogic()
{
m_ProjectDirectory = getcwd(NULL, 0);
int slashGamePos = m_ProjectDirectory.rfind(
);
m_ProjectDirectory = m_ProjectDirectory.substr(0, slashGamePos);
\\Game
 
 
 
Search WWH ::




Custom Search