Game Development Reference
In-Depth Information
// landing flaps down
if (IsKeyDown(0x46)) //f
// landing flaps up
if (IsKeyDown(0x44)) // d
Before StepSimulation is called, we check each of the flight control keys to see if it is
being pressed. If so, then the appropriate function is called.
The function IsKeyDown , which checks whether a certain key is pressed, looks like this
in a Windows implementation:
BOOL IsKeyDown(short KeyCode)
SHORT retval;
retval = GetAsyncKeyState(KeyCode);
if (HIBYTE(retval))
return TRUE;
return FALSE;
The important thing to note here is that the keys are being checked asynchronously
because it is possible that more than one key will be pressed at any given time, and they
must be handled simultaneously instead of one at a time (as would be the case in the
standard Windows message processing function).
The addition of flight control code pretty much completes the physics part of the sim‐
ulation. So far, you have the model, the integrator, and the user input or flight control
elements completed. All that remains is setting up the application's main window and
actually drawing something that represents what you're simulating. We'll leave that part
up to you, or you can look at the example we've included on the topic's website to see
what we did on a Windows machine.
Search Nedrilad ::

Custom Search