Game Development Reference
In-Depth Information
{
SetCapture(NULL);
result = m_PointerHandler->VOnPointerButtonUp(
CPoint(LOWORD(msg.m_lParam), HIWORD(msg.m_lParam)),
m_PointerRadius,
PointerRight
);
}
break;
default:
return 0;
}
return 0;
}
Did you notice that I used a reverse iterator for the screens? Here
s why: If you draw
them using a normal forward iterator, the screen on top is going to be the last one
drawn. User input should always be processed in order of the screens from top to
bottom, which in this case would be the reverse order.
If none of the screen elements in the list processed the message, we can ask the input
device handlers, in this case m_KeyboardHandler and m_PointerHandler ,to
process the messages. Of course, you could always write and add your own input
device handler, perhaps for a dance pad or gamepad if you do, here ' s where you
would hook it in.
Notice that the existence of the handler is always checked before the message is sent
to it. There
'
'
s nothing that says you have to have a keyboard for every game you
'
ll
make with this code, so it
'
s a good idea to check it.
A WASD Movement Controller
You might be wondering how you use this system to create a WASD movement con-
troller, since this interface requires the use of a mouse and a keyboard combined. In
Chapter 9,
you read about the IPointerHandler
and IKeyboardHandler interface classes. You can use these to create a single con-
troller class that can respond to both devices.
Programming Input Devices,
class MovementController : public IPointerHandler, public IKeyboardHandler
{
protected:
Mat4x4 m_matFromWorld;
Mat4x4 m_matToWorld;
Mat4x4 m_matPosition;
 
 
Search WWH ::




Custom Search