Coordinates and Isometric Grids

BlitzMax Forums/BlitzMax Programming/Coordinates and Isometric Grids

blackwater(Posted 2012) [#1]
Hi all. I'm in the process of creating an isometric grid for the purposes of placing isometric sprites and coordinates for AStar navigation. Let me preface this post by saying I don't have advanced math skills :)

So what I came up with last night is to run through a couple of For loops to create a large diamond and a bunch of smaller diamonds within that. My thinking is when I create it, I will know the X.Y coordinates of each corner (4 corners for each diamond tile). When I get the mouse coordinates, I will run through a custom List and know which tile was clicked on.

The problem is the size of the loop gets very big very quickly and my editor is clearly lagging because of it. To make a 100 x 100 isometric grid by drawing each line, that's 10000 runs. The map size is OK but I was hoping for bigger. Also, it seems really like a "brute force" method to have to run through thousands of nodes to find out which tile I clicked on.

Is there a better, faster way of doing this? The reason I'm drawing the lines is so I can see where I'm placing tiles (sprites) to line them up correctly. But then I started thinking if I'm somehow able to know what the coordinates are for each tile without pre-generating them I should be able to place the sprite and have it lock in to that tile without me having to visually make sure it's lined up correctly.

I have a few other ideas I haven't tried yet, the biggest one is generating the grid from an origin of known fixed coordinates, such as the top left of the screen somehow but haven't fleshed it out yet. I've read a bunch of articles off google but haven't really found anything of use, or at least anything that I can translate into simpler terms.

So anyone have any ideas or methods or another direction I can go in? I'm thinking this discussion will be helpful to other people as well since I can't be the only one wanting to create a large isometric grid.

Thanks in advance for help!


Enyaw(Posted 2012) [#2]
Maybe this code might be of some help to you and you might find some part of it that could help you out.




matibee(Posted 2012) [#3]
I'm not an expert in isometric games as such but in these cases it helps to have screen-to-world and world-to-screen transformation functions.

If you have a draw origin (of a scrolling map) a tile offset and a pixel inside that tile, you can calculate the actual screen coords (and prove it with a simple bit of test code.) That's world-to-screen. Then just reverse all those operations and you'll have a screen-to-world.

If you post some test code I can help you more.


Matt Merkulov(Posted 2012) [#4]
DWLab framework has isometric cameras with given coordinate system OX and OY vectors which code contains isometric screen-to-field and back transformations.