Isometric algorithm producing tiles in wrong draw order

Posted by David on Game Development See other posts from Game Development or by David
Published on 2012-06-25T03:26:24Z Indexed on 2012/06/25 15:23 UTC
Read the original article Hit count: 286

Filed under:
|
|
|

I've been toying with isometric and I just cant get the tiles to be in the right order. I'm probably missing something obvious and I just can't see it. Even at the risk of looking stupid, here's my code:

for (int i = 0; i < Tile.MapSize; i++)
{
    for (int j = 0; j < Tile.MapSize; j++)
    {
         spriteBatch.Draw(
            Tile.TileSetTexture, new Rectangle(
            (-j * Tile.TileWidth / 2) + (i * Tile.TileWidth / 2),
            (i * (Tile.TileHeight - 9) / 2) - (-j * (Tile.TileHeight - 9) / 2),
            Tile.TileWidth, Tile.TileHeight),
            Tile.GetSourceRectangle(tileID),
            Color.White,
            0.0f,
            new Vector2(-350, -60),
            SpriteEffects.None,
            1.0f);
    }
}

And here's what I end up with:

messed up map

Yep, bit of an issue. If anyone could help, I'd appreciate it.

© Game Development or respective owner

Related posts about XNA

Related posts about c#