Game Development Reference
In-Depth Information
void Camera::fly(float units)
{
if( _cameraType == AIRCRAFT )
_pos += _up * units;
}
12.3 Sample Application: Camera
This chapter's sample program creates and renders the scene shown in
Figure 12.8. You are free to fly around this scene using input from the
keyboard. The following keys are implemented:
W/S—Walk forward/backward
A/D—Strafe left/right
R/F—Fly up/down
Up/Down arrow keys—Pitch
Left/Right arrow keys—Yaw
N/M—Roll
Figure 12.8: A screen
shot of the camera
sample program for
this chapter
The implementation of the sample is trivial, since all the work is inside
the Camera class, which we have already discussed. We handle user
input in the Display function accordingly. Keep in mind that we have
instantiated the camera object TheCamera at the global scope. Also
notice that we move the camera with respect to the time change
( timeDelta ); this keeps us moving at a steady speed independent of
the frame rate.
bool Display(float timeDelta)
{
if( Device )
{
Search WWH ::




Custom Search