2D? Why Bother?
When
developing casual games, a problem we often face is trying to create a
pure 2D render base without 3D acceleration and creating the exact same
effect. But before diving into the solution, I think it’s important to
explain a bit more about why we need a 2D fallback in the first place.
3D
acceleration is a powerful tool. If we draw the 2D elements using 3D
triangles, the scene is probably like the one shown in Image 1 (below).
But really, they are just a bunch of triangles which are deliberately
aligned on a plane parallel with the camera.
This is a neat/uniform solution and is what the
hardcore 3D titles do. But if you are making a casual game like
the ones on Popcap or Real Arcade, you can’t assume everyone
has a gear with 3D acceleration. And even if they do, they may
not have the driver installed properly, because the target audiences
of casual games are people like our mums and dads.
So
in order to support these machines, we’ll need a pure 2D fallback. The
main job of a 2D render base is moving pixels. I mean something like
win32 API BitBlt() or StretchBlt() which transfer pixels from a
specified source rectangle to a specified destination rectangle,
altering the pixels according to the selected raster operation. You may
feel confused by now. What’s the fuss with BitBlt? Everyone knows how
to use it. I can even use DirectDraw if I like! But this is never an
easy task if you think about it seriously. The culprit this time is
combination explosion. Let me explain it to you.
Image 1: 2D elements are rendered as 3D triangles using hardware acceleration
|