We talked about sprites as containers, but containers for what? Well, sprites are containers for the humble bitmap. But, what’s a bitmap? Well, today, you’ll find out in detail.
Bitmap The Odds And Ends
Bitmaps are used to describe the images contained within the sprite. The bitmap contains all the relevant binary information on how to draw/render the image on the screen. So, then the bitmap would then contain some properties in code to represent it.
Since it’s an image, the bitmap would consist of width and height properties. And because it’s an image, it’s made up of binary information. With that image’s binary information, we can modify the pixels colors. Now, you might wonder what a pixel is. A pixel is a small colored square that makes up part of an image; an image is really a combination of many pixels. The width and height property of an image are based on how many pixels wide and tall it is. Just like anything in the code, we can also play around with pixels and make changes to what colors they represent.
The Power Of Bitmaps
The power of bitmaps lies within their flexibility. You can directly modify any bitmap you create in code with the properties mentioned above. Now, the power of modifying the pixels is the important part. You can draw shapes, change colors, and more. The flexibility is all thanks to the pixel information. So, let’s discuss pixels in-depth and why they’re important.
Pixels In Depth
As mentioned above, pixels are just squares on the screen. And each pixel is binary encoded information with its own properties. Each pixel has a set of properties represented in numbers; these are red (r), green (g), blue(b), and alpha(a). These four properties may also be referred to as channels. Each channel goes from a range of 0 – 255. Now, by combining different amounts on each channel, you can get just about any color at any opacity. This applies to every pixel within an image and is the foundation for drawing anything on a screen. Now, can you see how powerful the pixel and bitmaps really are? I hope this introduction helps you push yourself further as a game developer.