16.3 Tricks and Techniques

UP


16.3.1 Sparse Sprites

The buf in a bitmap entry may be NULL, indicating that nothing should be drawn. This area will be 100% transparent.

UP


16.3.2 Early-Ending Sprites

Setting the width of a bitmap entry to zero (0) signals an early exit to drawing the sprite's bitmaps.

UP


16.3.3 Variable Size Bitmaps

Each bitmap can have a different drawn "width" and the corresponding texture can have a different width_img. To vary the vertical size of a sprite, set the actual_height field. If this is bigger than the sprite's bmHeightReal, then this actual_height is used for loading TMEM.

UP


16.3.4 Explosions

Each sprite can specify the spacing between tiles in pixels by setting the explx and exply fields. The default value is zero (0). This spacing is not affected by the scaling of the sprite.

UP


16.3.5 Bitmap Re-use

If the buf of the current bitmap matches the buf of the previous bitmap (not counting NULL bufs) in this sprite, then TMEM will not be re-loaded. This very simple form of texture caching is used in the font example.

UP


16.3.6 Sprite Re-use

Each sprite has an associated display list and an associated rsp_dl_next pointer. When spDraw is called, new display list entries are added to the area pointed at by rsp_dl_next. This does not have to correspond to the pre-allocated display list allocated for the sprite; it could point somewhere else.

This allows a sprite to get drawn multiple times, each with a different setting of some parameters (position, scale, color, solid/textured, and so on). Sufficient display list area must be allocated for this to operate correctly.

UP