Game Development Reference
In-Depth Information
{
if(m_lastMousePos!=mousePos)
{
m_fTargetYaw = m_fTargetYaw + (m_lastMousePos.x - mousePos.x);
m_fTargetPitch = m_fTargetPitch + (mousePos.y - m_lastMousePos.y);
m_lastMousePos = mousePos;
}
return true;
}
This method was probably simpler than you expected. All it does is set the target yaw
and pitch of the controller to match the mouse movement. Here
'
s the real meat of
the controller, OnUpdate() :
void MovementController::OnUpdate(DWORD const deltaMilliseconds)
{
if (m_bKey[
'
W
'
] || m_bKey[
'
S
'
])
{
// code here will calculate movement forward & backward
}
if (m_bKey[
'
A
'
] || m_bKey[
'
D
'
])
{
// code here will calculate movement left & right
}
{
// code here will set object rotation based on
// previously calculated pitch and yaw values.
// then, the movements forward, backward, left or
// right will be used to send a movement command
// to the game logic, which will evaluate them
// for legality and actually move the object
}
}
Thefullcodeofthisroutinerequiressomedeeperknowledgeof3Dtransformations.
To avoid sending you into convulsions, I
'
ll postpone those discussions until Chapter 14.
Screen Elements
You ' ve seen how the human view works; its big job is managing the list of screen
elements, drawing them, sending them input, and managing a couple of things like
the audio system and the Process Manager. The audio system is discussed in detail in
 
 
Search WWH ::




Custom Search