This post is a portion of Part 6 in my on going series about 2D Game Development using the Allegro 5 library. These posts are in course order. You can see all of the posts in this course by clicking the “2D Game Development” button at the top of this site.

Bitmaps

Not very long ago we looked at drawing to the screen with 2D primitives. Now it is time to progress past that and look at a new way of representing our game objects: the bitmap. Truth be told, we have been using bitmaps all along. For instance, the back buffer we have been drawing to this whole time (part of the display, read my note on double buffering in Part 2.0 if you don’t remember) can be considered a bitmap. By definition, a bitmap is just a map of bits and while there is an image format named “bitmap” (.bmp), in Allegro we refer to just about any array if image data as a bitmap. By the same vein, once in our program, .jpg’s, .png’s, and many other format become bitmaps. Armed with this knowledge (and a general acceptance of the term “bitmap”), we can begin to really power up our games.

What can we do with a map… of bits?

Knowing with a bitmap is allows us to work with it in code. We can generate our own bitmaps on the fly, load bitmaps from a file or data stream, even save bitmaps to the hard drive (screenshots anyone?). Once in our game, bitmaps can be scaled, rotated, flipped, stretched, tinted, faded, and spliced. Not only that, but they tend to look a lot better than games drawn with just primitives (most of the time). One important thing (maybe the most important thing) that bitmaps allow us to do is easy, effective animation inside of our game. By leverage the power of transparency and multiple bitmap images, we can add a whole new level of animation to our game (more on that in Part 7).