Game Development Reference
In-Depth Information
Chapter 3. Rendering 2D Graphics
One of the biggest aspects in a video game is the graphics. It's why we call them
video games after all! So how do we create images on the screen? As we did with
user input in the previous chapter, we have a couple of options here. They are Direc-
t2D and Direct3D . We will focus on Direct2D in this chapter and save Direct3D for a
later chapter.
In this chapter we will cover the following topics:
• Creating a Direct2D game window class
• Drawing a rectangle on the screen
• Creating a 2D tile-based game world and entities
Creating a Direct2D game window class
We are finally ready to put some graphics on the screen! The first step for us is to
create a new game window class that will use Direct2D. This new game window class
will derive from our original game window class, while adding the Direct2D functional-
ity.
Note
You'll need to download the code for this chapter as some code is omitted to save
space.
Open Visual Studio and we will get started with our Ch03 project. Add a new class to
the Ch03 project called GameWindow2D . We need to change its declaration to:
public class GameWindow2D : GameWindow,
IDispoable
As you can see, it inherits from the GameWindow class meaning that it has all of the
public and protected members of the GameWindow class, as though we had imple-
Search WWH ::




Custom Search