31.2. Using a background bitmap

Suppose we want to use a background bitmap as a resource. The basic idea is that when we draw the view we want to do the following.

  • Copy the background bitmap to a memory window.
  • Write the critter sprites on top of the memory window as well.
  • Copy the memory window to the screen.

What we need to do is to store our background bitmap in a ready-to-use form. At the high level, we wrap it up inside a cSpriteIcon object. In Windows graphics, we implement the image as a cMemoryDC, and in OpenGL we save it as a cTexture – both of which are classes invented for use in the Pop Framework.

A complication comes up. We want our program to be size-independent; that is, if we resize the window, we want the whole background ...

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.