Game Development Reference
In-Depth Information
public:
TeapotWarsHumanView(shared_ptr<IRenderer> renderer);
virtual
TeapotWarsHumanView();
˜
virtual LRESULT CALLBACK VOnMsgProc( AppMsg msg );
virtual void VRenderText();
virtual void VOnUpdate(unsigned long deltaMs);
virtual void VOnAttach(GameViewId vid, ActorId aid);
virtual void VSetControlledActor(ActorId actorId);
virtual bool VLoadGameDelegate(TiXmlElement* pLevelData) override;
// event delegates
void GameplayUiUpdateDelegate(IEventDataPtr pEventData);
void SetControlledActorDelegate(IEventDataPtr pEventData);
private:
void RegisterAllDelegates(void);
void RemoveAllDelegates(void);
};
This class manages a number of view objects and relies on the HumanView class to
handle most of the heavy lifting It has a reference to the TeapotController for
handling player input, a MovementController that implements the debug free-fly
camera, a teapot scene node, which represents the currently controlled teapot, and a
StandardHUD object for UI rendering.
Like the application layer and game logic, most of the functions defined in this class
are either overridden virtual functions or event handler delegates. The delegates han-
dle events coming from the Lua code. You
ll see those later in this chapter. The other
functions are implementations of techniques you
'
ve learned on how to render text
and manage a scene in Direct3D. The TeapotWarsHumanView class can be found at
Dev/Source/TeapotWars/TeapotWarsView.h and TeapotWarsView.cpp.
A game view that presents the game to a human needs a way for that human to affect
the game. It
'
s a common practice to factor control systems that have a particular
interface, like the keyboard WASD controls, into a class that can be attached and
detached as necessary. This controller class isn
'
'
t exactly WASD, since the A and D
keys control steering rather than strafing, but I
'
m sure you
'
ll forgive the departure.
class TeapotController : public IPointerHandler, public IKeyboardHandler
{
protected:
bool
m_bKey[256];
// Which keys are up and down
shared_ptr<SceneNode> m_object;
Search WWH ::




Custom Search