Better approach store the entire sprite image set single bitmap
is satisfactory and which one is selected is a matter of coding convenience. SetTimer() has the following general form:
UINT SetTimer(
HWND hWnd, // 1
UINT nIDEvent, // 2
UINT uElapse, // 3
TIMERPROC lpTimerFunc // 4
);In graphics programming, particularly in game programming, a sprite is a rather small screen object, usually animated at display time. Sprite animation can be simple or complex. In simple animation an object represented in a single bitmap is animated by translating it to other screen positions, or the object itself performs an intrinsic action, for example, a rotating wheel. In complex animation both actions are performed simultaneously: a rocket moves on the screen until it reaches a point where it explodes. Sprites are typically encoded in one or more images that represent the object or its action sequence. The images can be stored in separate bitmaps, or in a single one. Figure 12-3 shows the image set of a dagger sprite that revolves around its own axis.
When the twenty images in the set of Figure 12-3 are rapidly displayed, the dagger appears to rotate 180 degrees. If the images are also translated from one screen position to another, the sprite simulates the movement of a thrown dagger. This last action would be a case of complex sprite animation.
Sprites often use a source color key to achieve transparency. To automate sprite color keying, some applications assume that the pixel at the top-left corner of the bitmap is the color key. Later in this chapter we discuss the use of dynamic color keys. It is possible to encode each image of the sprite image set in separate bitmaps, but this usually leads to many disk files and complicated file access operations. A better approach is to store the entire sprite image set in a single bitmap, and then use source rectangle selection capability of either the Blt() or BltFast() functions to pick the corresponding image.


