Chapter 3. 2D Rendering

We have made good progress on the Advanced2D engine in short time, and we have a few more key features to add before we’ll have a viable engine for building the games we need to explore later in this book. It goes without saying that we need 2D rendering support! Even the most advanced 3D engine today needs to support 2D rendering for things such as text output and a graphical user interface.

There are two ways to render 2D objects in Direct3D. First, you can create a quad (or rectangle) comprised of two triangles with a texture representing the 2D image you wish to draw. This technique works with and even supports transparency, responds to lighting, and can be moved in the Z direction. The second method available in Direct3D for rendering 2D objects is with sprites—and this is the method we will focus on in this chapter. A sprite is a 2D representation of a game entity that usually must interact with the player in some way. A tree or rock might be rendered in 2D and interact with the player by simply getting in the way, stopping the player by way of collision physics.

We must also deal with game characters that directly or indirectly interact with the player’s character (which might be a spaceship, an Italian plumber, or a spiky-haired hedgehog). The types of sprites that interact with the player might be an enemy ship or a laser in a space combat game—I could go on and on with examples.

Advice

The Advanced2D engine will evolve from one chapter to the next as it gains new classes and capabilities. This is normal for software development—nothing is set in stone yet! Every aspect of the engine will change over time to accommodate new features and needs that are identified through the development of demo programs. By presenting the engine in lock-step fashion as you see here, you are able to watch the engine develop from its early stages into the fully featured version used in the final chapters.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset