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

  • Home
  • SEARCH
  • 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 8755369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:50:34+00:00 2026-06-13T13:50:34+00:00

So my issue is, usually when I generate my maps I’d use the following:

  • 0

So my issue is, usually when I generate my maps I’d use the following:

for(int x = 0; x < width; x++) {
    for(int y = 0; y < height; y++) {
       tiles.add(new Tile(x, y));
    }
}

You can get the just of that.
Anyway I need to pretty much have pragmatic way of doing this in an isometric / 45 degree rotation.

Say the first loop you’d add new Tile(width / 2, 0).

Next loop you’d add new Tile((width / 2) – 1, 0), and new Tile((width / 2) + 1, 0).

I’ve experimented with a few differing ways to do this, but haven’t had much success.

  • 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-06-13T13:50:35+00:00Added an answer on June 13, 2026 at 1:50 pm

    If I understand correctly, it seems like you’re trying to represent the tiles for an isometric game, e.g.:

    enter image description here

    For this, your Tiles store the (x,y) information of their location with the following layout:

    y \ x | 0 | 1 | 2 | 3 | 4 | 5 | 6
    ------+---+---+---+---+---+---+---
       0  |   |   |   | A |   |   |
    ------+---+---+---+---+---+---+---
       1  |   |   | B |   | C |   |
    ------+---+---+---+---+---+---+---
       2  |   | D |   | E |   | F |
    ------+---+---+---+---+---+---+---
          |   |   |   |   |   |   |
    

    and so on.

    However, I would suggest to decouple the internal representation of your tile grid from the way it is displayed. Just because you want isometric graphics doesn’t necessarily mean that you have to store your Tiles’ (x,y)-positions in a diamond shape as well.

    Instead, try the following layout for each of your tiles:

    y \ x | 0 | 1 | 2 | 3 
    ------+---+---+---+---
       0  | A | C | F | 
    ------+---+---+---+---
       1  | B | E |   | 
    ------+---+---+---+---
       2  | D |   |   | 
    ------+---+---+---+---
          |   |   |   | 
    

    That is, tile A is created as new Tile(0,0), tile B as new Tile(0,1), etc.

    With this representation you’ll get the advantage that adjacent tiles in your isometric display will only differ by 1 in either the x- or the y-direction. This should make the initialization step of your tiles list much easier.

    To map these coordinates to the isometric display positions, remember that tile A at location (0,0) is at the top of the diamond. You can then compute the display positions of all other tiles relative to that one:

    • The difference in the x-coordinate translates to moving right and down
    • The difference in the y-coordinate translates to moving left and down

    So let’s assume your display renders A at the pixel coordinates (px, py), and every tile is rendered with a width of pWidth and a height of pHeight.

    The horizontal offset for tile can then be computed by walking right tile.x times and walking left tile.y times. Because of the isometric view, you only offset by half of the width in every step.

    int pxTile = (tile.x - tile.y) * pWidth / 2 + px;
    

    The vertical offset is computed similarly. While tile.x and tile.y cancel each other out in the horizontal directorion (since left and right are opposite of each other), they both contribute to moving down in the vertical direction.

    int pyTile = (tile.x + tile.y) * pHeight / 2 + py;
    

    Unless your game does scrolling/zooming, you can compute the pixel coordinates of every Tile right in the constructor, because they only depend on the values of (x,y) and the constants width, px, py, pWidth, and pHeight.

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

Sidebar

Related Questions

Issue Using the following just simply doesn't work properly in -webkit- and -moz- browsers:
Issue for text elements that are adjacent to icon elements, the glyph height is
// issue with the following not returning info or just stalling... but no errors
I have an issue that I feel many programmers can relate to... I have
I've been having a little issue with image URLs. Usually I wouldn't care about
i'm trying to upgrade an old CMS to use NHibernate and can't deter from
In C# from time to time the issue creeps out. Usually I get an
The following issue is becoming increasing common: There are several developers working on a
Hi Just started learning c for uni (usually use objective c) and have run
I don't understand this issue. Because this usually worked till now. This method is

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.