Chapter 6: 2D Stuff Every Game Programmer Should Know


Overview

I used to play a great kid's game called Lite Brite that let me create pictures by pushing little pieces of colored plastic into a black screen brightly backlit with a light bulb. I made some pretty bizarre stuff with this game. I'm sure my parents never realized that more than thirty years later I'd be still playing with little bits of color on a screen. The bits of color are now moving a whole hell of a lot faster, and there are millions more of them. I remember finding out how graphical displays worked, and I recall being surprised at how easy it seemed. Each pixel is drawn using the contents of a range of video memory. If I change the value stored in that memory, I'll notice a color change in one of the pixels. How elegant and cool! What can I say, I was a geek.

After my initial joy wore off, I discovered that getting the right pixel to change or getting the right color was easy but the system had some tricks to it. Not every video card stored pixels in the same format and accessing each pixel wasn't as simple as tweaking values in a two dimensional array of values. Then the hard stuff began. I wanted to draw shapes, text, and scenes all blended together with nice translucent effects. This stuff is also not hard, but my trivial implementations also dropped the frame rate to embarrassing levels. In other words, making pretty pictures is still easy; making them at 60+ frames per second is trickier than you'd think.

For those of you who are already thinking of skipping this chapter in favor of reading some juicy 3D tricks, hang tight. One of the fastest growing areas of the computer game industry is handheld stuff. Games are being written for cell phones, Pocket PCs, and the GameBoy Advance. There's a renaissance of retro 2D gaming out there so don't think for a second that pushing pixels instead of polygons is a waste of your time. Besides, every 3D game I see still has plenty of 2D screens, animations, and other goodies. You need to walk before you can run, so we'll start back with drawing little blobs of color in this chapter, and see where it goes.

Let me say this again for emphasis: 2D is far from dead, as much as DirectX 8 would have you believe. 2D is coming back with a vengeance, and if all you know how to do is push polys, you're going to miss out on some of the best stuff that has happened to computer gaming in a long time. Nintendo's Game Boy Advance and Nokia's latest cell phones do not have 3D hardware acceleration.




Game Coding Complete
Game Coding Complete
ISBN: 1932111751
EAN: 2147483647
Year: 2003
Pages: 139

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net