Navigation
Last updated: 2004-03-23
|
Drawing isometric maps
There are many good tutorials on the net for drawing isometric maps, the one Haphazard is based on is http://www.isometrix.org/archives/articles/jim_adams/engine.htm that was found on the isometrix project. Now, the acute reader will notice the based on above, now what changes have we made? And why? Basically, we've changed the drawing routine to get a better overlook of the code and perhaps made it faster. Now, if you've read up on your isometric drawing, you'll know that we draw in rows. How many rows do we need to draw totally?
OK, now we know how many rows to draw, which tile starts each row?
TileY = min(row, Number_of_Y_tiles - 1); Now we need to figure out how many tiles to draw, we know that we should increase x by one and decrease y by one for each tile drawn. When do we stop?
TileY >= max(row-(Number_of_X_Tiles - 1), 0) So that's basically it, these few algorithms gives us the code (in Java):
{ int x = Math.max(row - (mArray[0].length - 1), 0); int y = Math.min(row, mArray[0].length - 1); while (x <= Math.min(row, mArray.length - 1) && y >= Math.max(row-(mArray.length - 1), 0)) { //draw tile Tile tile = mArray[x][y]; ... // Go to next tile x++; y--; // Increase screen coordinate for next tile } // Reset current screen coordinate to next row // Use start criteria for x and y to figure out screen coordinate currentScreenCoordinate.x = screenCoordinate.x + (Math.max(row+1-(mArray[0].length-1), 0) - Math.min(row+1, mArray[0].length-1)) * halfTileWidth; } |