Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 215697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:29:42+00:00 2026-05-11T18:29:42+00:00

What is the correct way to draw isometric tiles in a 2D game? I’ve

  • 0

What is the correct way to draw isometric tiles in a 2D game?

I’ve read references (such as this one) that suggest the tiles be rendered in a way that will zig-zag each column in the 2D array representation of the map. I imagine that they should be drawn more in a diamond fashion, where what gets drawn to the screen relates more closely to what the 2D array would look like, just rotated a little.

Are there advantages or disadvantages to either method?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:29:42+00:00Added an answer on May 11, 2026 at 6:29 pm

    Update: Corrected map rendering algorithm, added more illustrations, changed formating.

    Perhaps the advantage for the “zig-zag” technique for mapping the tiles to the screen can be said that the tile’s x and y coordinates are on the vertical and horizontal axes.

    “Drawing in a diamond” approach:

    By drawing an isometric map using “drawing in a diamond”, which I believe refers to just rendering the map by using a nested for-loop over the two-dimensional array, such as this example:

    tile_map[][] = [[...],...]
    
    for (cellY = 0; cellY < tile_map.size; cellY++):
        for (cellX = 0; cellX < tile_map[cellY].size cellX++):
            draw(
                tile_map[cellX][cellY],
                screenX = (cellX * tile_width  / 2) + (cellY * tile_width  / 2)
                screenY = (cellY * tile_height / 2) - (cellX * tile_height / 2)
            )
    

    Advantage:

    The advantage to the approach is that it is a simple nested for-loop with fairly straight forward logic that works consistently throughout all tiles.

    Disadvantage:

    One downside to that approach is that the x and y coordinates of the tiles on the map will increase in diagonal lines, which might make it more difficult to visually map the location on the screen to the map represented as an array:

    Image of tile map

    However, there is going to be a pitfall to implementing the above example code — the rendering order will cause tiles that are supposed to be behind certain tiles to be drawn on top of the tiles in front:

    Resulting image from incorrect rendering order

    In order to amend this problem, the inner for-loop’s order must be reversed — starting from the highest value, and rendering toward the lower value:

    tile_map[][] = [[...],...]
    
    for (i = 0; i < tile_map.size; i++):
        for (j = tile_map[i].size; j >= 0; j--):  // Changed loop condition here.
            draw(
                tile_map[i][j],
                x = (j * tile_width / 2) + (i * tile_width / 2)
                y = (i * tile_height / 2) - (j * tile_height / 2)
            )
    

    With the above fix, the rendering of the map should be corrected:

    Resulting image from correct rendering order

    “Zig-zag” approach:

    Advantage:

    Perhaps the advantage of the “zig-zag” approach is that the rendered map may appear to be a little more vertically compact than the “diamond” approach:

    Zig-zag approach to rendering seems compact

    Disadvantage:

    From trying to implement the zig-zag technique, the disadvantage may be that it is a little bit harder to write the rendering code because it cannot be written as simple as a nested for-loop over each element in an array:

    tile_map[][] = [[...],...]
    
    for (i = 0; i < tile_map.size; i++):
        if i is odd:
            offset_x = tile_width / 2
        else:
            offset_x = 0
    
        for (j = 0; j < tile_map[i].size; j++):
            draw(
                tile_map[i][j],
                x = (j * tile_width) + offset_x,
                y = i * tile_height / 2
            )
    

    Also, it may be a little bit difficult to try to figure out the coordinate of a tile due to the staggered nature of the rendering order:

    Coordinates on a zig-zag order rendering

    Note: The illustrations included in this answer were created with a Java implementation of the tile rendering code presented, with the following int array as the map:

    tileMap = new int[][] {
        {0, 1, 2, 3},
        {3, 2, 1, 0},
        {0, 0, 1, 1},
        {2, 2, 3, 3}
    };
    

    The tile images are:

    • tileImage[0] -> A box with a box inside.
    • tileImage[1] -> A black box.
    • tileImage[2] -> A white box.
    • tileImage[3] -> A box with a tall gray object in it.

    A Note on Tile Widths and Heights

    The variables tile_width and tile_height which are used in the above code examples refer to the width and height of the ground tile in the image representing the tile:

    Image showing the tile width and height

    Using the dimensions of the image will work, as long as the image dimensions and the tile dimensions match. Otherwise, the tile map could be rendered with gaps between the tiles.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would you correct way to handle an exception in this situation? Initially I
I always assumed that the correct way to calculate the FPS was to simply
What is an efficient way to draw sprites in my 2D XNA game? To
What is the correct way to add a product variant? I create the product
What's the correct way to set a flash message for the current view but
Which is correct way to extend/subclass components? Ext.define('Holidays.Components.UserInfo', { extend: 'Ext.panel.Panel', alias: 'widget.UserInfo', region:
What is the correct way to use pygame.Color names when using unicode_literals ? Python
What would be the correct way to create a fully URL-encoded file:// URI from
What's the correct way to prevent invoking (creating an instance of) a C type
What is the correct way to do conditional formatting in Django? I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.