public void Draw(GameTime gameTime, int layer)
{
Vector2 center = (Game as Game1)._player.GetPosition();
Game1 game = (this.Game as Game1);
// Layer evtl. in Klasse (DrawableGameComponent) kapseln
for (int y=0; y<_grid[layer].GetLength(1); ++y)
{
for (int x = 0; x < _grid[layer].GetLength(0); ++x)
{
int width = (int)Math.Floor((double)game._tileSetTexture.Width / Constants.TileSize);
game._spriteBatch.Draw(
game._tileSetTexture,
new Rectangle(x * Constants.TileSize - (int)center.X + (int)Math.Round(game.Window.ClientBounds.Width / 2.0f),
y * Constants.TileSize - (int)center.Y + (int)Math.Round(game.Window.ClientBounds.Height / 2.0f),
Constants.TileSize, Constants.TileSize),
new Rectangle((_grid[layer][x, y] % width) * Constants.TileSize,
(_grid[layer][x, y] / width) * Constants.TileSize,
Constants.TileSize,
Constants.TileSize),
Color.White);
}
}
}