Game Development Reference
In-Depth Information
The next set of virtual methods starting with VOnRestore() and ending with VOnUp-
date() completes the implementation of the IGameView interface originally discussed
back in Chapter 2. You
llseewhateachofthesemethodsisresponsibleforshortly.
The next two virtual methods, VPushElement() and VRemoveElement() , control
the ordering and layering of screen interface elements.
The next data member is an STL list of pointers to objects that implement the
IScreenElement interface. A screen element is a strictly user interface thing and
is a container for user interface controls like buttons and text edit boxes. You could
have a number of these components attached to do different things, and because they
are separate entities, you could hide or show them individually. A good example of
this kind of behavior is modular toolbars in the Window GUI.
The next two members are a generic pointer handler and a keyboard handler. You
'
ll
create pointer and keyboard handlers to interpret device messages into game com-
mands. Notice the member m_pointerRadius ? Even on Windows games, you
can
'
t count on the pointer device having pixel perfect accuracy anymore. With tablet
computers and cameras detecting human input in the place of a mouse, it makes sense
for your pointer interface to also keep track of a pointer radius along with its location.
This way you can do hit detection with an area instead of a single X,Y coordinate.
The next member is InitAudio() , which does exactly what is says
'
initializes the
audio system. After that is a stubbed utility method for setting the camera offset,
which will be implemented by a child class in Chapter 21,
A Game of Teapot
Wars,
at the end of the topic.
Let
s take a look at some of the more interesting bits of the HumanView class, starting
with the VOnRender() method. The render method is responsible for rendering the
view at either a clamped maximum refresh rate or at full speed, depending on the
value of the local variables.
'
void HumanView::VOnRender(double fTime, float fElapsedTime )
{
m_currTick = timeGetTime();
// early out
ve already drawn in this tick
if (m_currTick == m_lastDraw)
return;
-
we
'
HRESULT hr;
// It is time to draw ?
if( m_runFullSpeed ||
( (m_currTick - m_lastDraw) > SCREEN_REFRESH_RATE) )
Search WWH ::




Custom Search