'Sprite' is a word traditionally used in computer game programming for the little character images that move around. Normally, computer game sprites are based on bitmaps, and we do indeed have a cSpriteIcon child of the cSprite class that uses bitmap images.
We also have some geometrical sprite objects. The cSprite child classes, cPolygon and cSpriteCircle, draw polygons and disks, respectively. Geometrical objects have the virtue of being scale-independent, crisp-looking, and lightweight in terms of memory use. Another good thing about them is that they can be easily rotated. Bitmaps can be rotated in OpenGL graphics, but not in Windows graphics.
Exercise 9.11 discusses how to create sprites of a variety of standard 3D shapes: sphere, cone, torus, tetrahedron, cube, octahedron, dodecahedron, icosahedron, and teapot.
The cSpriteComposite class uses the Composite software pattern to provide for sprites which are made up of component sprites. The cSpriteBubble is a composite holding a cSpriteCircle and a decorative cPolygon highlight. cPolyPolygon is a special kind of composite drawn as a polygon with polygons (or polypolygons) at its vertices.
The cSpriteShowOneChild of cSpriteComposite shows only one of the components rather than all of them. How might we choose which component to show? We might either look at the direction the sprite is currently moving in, getting the cSpriteDirectional, or we might track the passage of time and continually flip through an animation loop of sprites like the cSpriteLoop does.
Figure 9.1 is a UML class diagram of the cSprite classes used in the Pop Framework.
Students are usually most interested in the bitmap-based sprite cSpriteIcon ; this is initialized from a *.bmp file that you add to your project resource. These work very well in Windows graphics, but in our three-dimensional OpenGL graphics, they run a bit slow. We presently implement the OpenGL bitmap sprites as texture maps that are applied to rectangles. In both the Windows and OpenGL graphics, we have the option of giving transparent backgrounds to our cSpriteIcon objects.
One can chain these constructions and have, for instance, a cSpriteDirectional that is an array of cSpriteLoop objects, so that one sees a different animation depending on the direction of the critter's motion. This is useful, for instance, for showing a running human form.