Skip to content

Instantly share code, notes, and snippets.

@painquin
Created February 12, 2010 20:59
Show Gist options
  • Save painquin/302975 to your computer and use it in GitHub Desktop.
Save painquin/302975 to your computer and use it in GitHub Desktop.
tileset.Texture = Content.Load<Texture2D>(tileset.File);
tileset.spacing = (Math.Sqrt(64 * 64 + 48 * 48));
double a = Math.Atan2(48, 64);
tileset.cos = Math.Cos(a);
tileset.sin = Math.Sin(a);
-----------------------------------------------
for (int y = 0; y < mapHeight; ++y)
{
for (int x = 0; x < mapWidth; ++x)
{
drawX = (float)((viewOffset.X * 5 + tileset.cos * x - tileset.sin * y) * tileset.spacing);
drawY = (float)((viewOffset.Y * 5 + tileset.sin * x + tileset.cos * y) * tileset.spacing);
int index = mapIndices[x,y];
tile = tileset.Tiles[index];
spriteBatch.Draw(tileset.Texture, new Vector2(drawX + (screenWidth + tile.Width)/ 2, screenHeight / 2 - drawY - tile.Height),
tile, Color.White);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment