public void Draw(SpriteBatch batch)
{
Vector2 topLeft = new Vector2(0.0f, 0.0f);
Vector2 bottomRight = new Vector2(Globals.screenWidth, Globals.screenHeight);
Vector2 topLeftTile, bottomRightTile;
int x, y;
// Obtain the top left and bottom right tiles according to our world coordinates
topLeftTile = screenToWorld(topLeft);
bottomRightTile = screenToWorld(bottomRight);
//Loop through the tiles that we know to be on the screen.
for (y = (int)topLeftTile.Y; y <= (int)bottomRightTile.Y; y++)
{
for (x = (int)topLeftTile.X; x <= (int)bottomRightTile.X; x++)
{
//get the id of the tile at the current position
UInt16 id = Grid(x, y);
//Render the correct texture at the current position
drawOnMap(batch, tiles[id], new Vector2((float)x, (float)y));
}
}
}