9.2. The cSprite class

Now let’s look at what goes inside a cSprite. A sprite does not need to know the name of its owner cCritter. This is the way it should be, as a sprite is simply some geometry in space, possibly textured with a bitmap. This makes life easier as maintaining a cCritter * pointer inside cSprite while maintaining an ‘inverse’ cSprite * pointer inside cCritter would be a bit of a hassle, particularly when it came to writing the destructors for these objects.

A sprite is something that a critter uses to draw a picture of itself. We will think of the size of a critter as being the visual size of its sprite. So a sprite will have a Real _radius field. Our decision was to have the _radius belong to the sprite rather than the critter, ...

Get Software Engineering and Computer Games now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.