Game Development Reference
In-Depth Information
Next,let'sturnourattentiontocreatingthemembervariablesforthe TileGameWin-
dow class. You can add these just below the structs we just created as follows:
WindowRenderTarget m_RenderTarget;
Factory m_Factory;
Player m_Player;
SlimDX.Direct2D.Bitmap m_PlayerSprites;
SlimDX.Direct2D.Bitmap m_TileSheet;
List<Tile> m_TileList;
int[ , ] m_Map;
SolidColorBrush m_DebugBrush;
The first two member variables should be familiar from the rectangle program that
we wrote at the beginning of this chapter. The m_Player variable holds a Player
object. This is the first struct we created earlier. The next two variables will hold the
bitmap images we will use for this program. One holds the sprites that make up the
animation for our player character, and the other one will hold the tile sheet that we
will use to draw the game world. The next variable is a list named m_TileList . We
will fill this with one entry for each tile type that we have. The m_Map variable, as you
might guess, will contain a map of our game world. And lastly, we have a SolidCo-
lorBrush member variable named m_DebugBrush .
Initialization
Now, it's time to create the constructor and start initializing everything. First, we need
to set up the render target. This is very similar to how we did it in the program for
creating a rectangle, but slightly different. The following is the code:
m_Factory = new Factory();
RenderTargetProperties rtProperties = new
RenderTargetProperties();
rtProperties.PixelFormat = new
PixelFormat(SlimDX.DXGI.Format.B8G8R8A8_UNorm,
Search WWH ::




Custom Search