Game Development Reference
In-Depth Information
CPoint
m_lastMousePos;
BYTE
m_bKey[256];
// Which keys are up and down
// Orientation Controls
float
m_fTargetYaw;
float
m_fTargetPitch;
float
m_fYaw;
float
m_fPitch;
float
m_fPitchOnDown;
float
m_fYawOnDown;
float
m_maxSpeed;
float
m_currentSpeed;
shared_ptr<SceneNode> m_object;
public:
MovementController(shared_ptr<SceneNode> object,
float initialYaw, float initialPitch);
void SetObject(shared_ptr<SceneNode> newObject);
void OnUpdate(DWORD const elapsedMs);
public:
bool VOnPointerMove(const CPoint &mousePos, const int radius);
bool VOnPointerButtonDown(const CPoint &mousePos, const int radius,
const std::string &buttonName);
bool VOnPointerButtonUp(const CPoint &mousePos, const int radius,
const std::string &buttonName);
bool VOnKeyDown(const BYTE c) { m_bKey[c] = true; return true; }
bool VOnKeyUp(const BYTE c) { m_bKey[c] = false; return true; }
const Mat4x4 *GetToWorld() { return &m_matToWorld; }
const Mat4x4 *GetFromWorld() { return &m_matFromWorld; }
};
I
'
m giving you something of a sneak peak into Chapter 14,
3D Graphics Basics,
with the introduction of the Mat4x4 member variables. I won
t explain them in
detail here, but suffice it to say that these members track where an object is in rela-
tion to the game world and how it is oriented.
Since this WASD controller doesn
'
ll simply return
false from the mouse button up and down handlers. Notice that the VOnKeyUp()
and VOnKeyDown() methods simply set members of a Boolean array to be true or
false to match the state of the key. Now, take a look at VOnPointerMove() :
'
t have any weapons to fire, we
'
bool MovementController::VOnPointerMove(const CPoint &mousePos)
Search WWH ::




Custom Search