Game Development Reference
In-Depth Information
chapter to see the complete array initialization code, which is much larger than the
earlier example.
Rendering the game world
For clarity, we will create a couple of different render methods that will each be called
from our RenderScene() method. Since the first thing we need to draw is the game
world itself, let's create that method first. We will name this method RenderWorld :
public void RenderWorld()
{
Tile s;
// Loop through the y axis.
for (int y = 0; y < m_Map.GetLength(0); y++)
{
// Loop through the x axis.
for (int x = 0; x < m_Map.GetLength(1);
x++)
{
// Get the tile at the current
coordinates.
s = m_TileList[ m_Map[y, x] ];
// Render the tile.
m_RenderTarget.DrawBitmap(m_TileSheet,
new Rectangle(x * 32, y * 32,
32, 32),
1.0f,
InterpolationMode.Linear,
new Rectangle(s.SheetPosX * 32,
s.SheetPosY * 32,
32, 32));
}
}
}
Search WWH ::




Custom Search