Game Development Reference
In-Depth Information
Figure 11-11. A simple example of first-person-shooter controls, without multitouch for simplicity
Pretty nice, right? It also doesn't take a lot of code, either, thanks to the wonderful job our helper
classes do for us. Now, adding multitouch support would be awesome, of course. Here's a hint:
instead of using polling, as in the example just seen, use the actual touch events. On a “touch
down� event, check whether the button was hit. If so, mark the pointer ID associated with it as
not being able to produce swipe gestures until a corresponding “touch up� event is signaled.
Touch events from all other pointer IDs can be interpreted as swipe gestures!
A Look-At Camera
The second type of camera usually found in games is a simple look-at camera. It is defined
by the following:
ï?®
A position in space.
ï?®
An up vector. Think of this as an arrow that you would see if you slapped
a “This Side Up� sticker on the back of the camera when your camera is
sitting flat on a level surface.
ï?®
A look-at position in space or, alternatively, a direction vector. We'll use the
former.
ï?®
A field of view in degrees.
ï?®
A viewport aspect ratio.
ï?®
A near clipping plane distance and a far clipping plane distance.
The only difference between a look-at camera and the Euler camera is the way we encode the
orientation of the camera. In this case, we specify the orientation by the up vector and the
look-at position. Let's write a helper class for this type of camera. Listing 11-11 shows the code.
 
Search WWH ::




Custom Search