Feature: 'A 2D Render Base Using Policy Based Design'
In this <a href="http://www.gamasutra.com/features/20061101/feng_01.shtml">Gamasutra technical article</a>, Chinese casual games programmer Zhaolin Feng gives us his tuto...
![](https://eu-images.contentstack.com/v3/assets/blt740a130ae3c5d529/bltba62518415cda0e2/652fe6ddbc479f8697ef691f/default-cubic.png?width=1280&auto=webp&quality=95&format=jpg&disable=upscale)
In this Gamasutra technical article, Chinese casual games programmer Zhaolin Feng gives us his tutorial on creating a fluid 2D render base, using a technique inspired by Scott Meyers' Modern C++ Design. In his intro, Feng explains that even though creating a polygonal 2D engine can achieve great results through hardware acceleration, a more traditional 2D solution might be preferable for maximum compatibility: "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. [...] 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 the ones 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." You can now read the full Gamasutra feature on the subject, including full code examples and downloadable source for Feng's 2D solution (no registration required, please feel free to link to this column from external websites).
About the Author
You May Also Like