Game Development Reference
In-Depth Information
// Interface sensitive objects
shared_ptr<IPointerHandler> m_PointerHandler;
int m_pointerRadius;
shared_ptr<IKeyboardHandler> m_KeyboardHandler;
// Audio
bool InitAudio();
//Camera adjustments.
virtual void VSetCameraOffset(const Vec4 & camOffset ) { }
protected:
virtual bool VLoadGameDelegate(TiXmlElement* pLevelData) { return true; }
};
Let
s take a quick look at the data members of this class. The first two members store
the view ID and the actor ID, if it exists. This makes it easy for the game logic to
determine if a view is attached to a particular actor in the game universe.
The ProcessManager was presented in Chapter 7, Controlling the Main Loop.
This class is a convenient manager for anything that takes multiple game loops to
accomplish, such as playing a sound effect or running an animation.
The next four members deal with drawing the frame. The first three keep track of
when the view was rendered last and whether or not to limit the frame rate. It is
typically a good idea to set your game to a constant frame rate, typically 60 frames
per second, leaving the rest of the time for other operations like AI, physics, and
other game-specific things. The last member stores the background color the view is
cleared to every frame. If your game is guaranteed to draw every pixel each frame,
you could set the color to RGB 255,0,255, and if for some reason some pixels were
missed, you would see a hot pink flash. In the release build, you could save a few
cycles by simply not clearing the frame at all. It ' s totally up to you.
The next member, VRenderText() , is stubbed out. This member, once overloaded
in an inherited class, is what is called when text-specific elements need to be drawn
by the view. In a DirectX supported game, this would eventually wind up in calls to
the CDXUTTextHelper class. I
'
'
m sure all you OpenGL fans can easily swap in your
own equivalents if you like.
The next two methods, LoadGame() and the protected VLoadGameDelegate() ,
are called when the game loads. LoadGame() is responsible for creating view-
specific elements from an XML file that defines all the elements in the game. This
might include a background music track, something that could be appreciated by
the human playing but is inconsequential for the game logic.
Search WWH ::




Custom Search