Isometric Tile Index From Position
BlitzMax Forums/BlitzMax Programming/Isometric Tile Index From Position
| ||
Hey, this is a solution I had a hard time to find myself, so I thought I'd share it with you. It basically allows you to convert from a 2d position to the x/y index of the underlying isometric tile. With a horrible amount of border cases to consider, you really won't wanna reinvent the wheel there. Feel free to use, modify, sell, marry my code :) Theres propably a dozen approaches, what I can claim about mine is that it is fast, numerically stable, and last but not least working perfectly accurate. Here is a screenshot of the testing application I wrote for the algorithm: Here is the coresponding code. Check out the <getTileIndizesAtPosition> Method to see the algorithm. Eventually part of the code originates from an upcoming engine of mine, so don't wonder about identifiers like "isoWorld" :) |
| ||
nice! Thanks. |
| ||
thanks i use iso myself, ill check it out |
| ||
Was in B3D, should work here too after changing it to MaxCode The bordercheck can be done with little additional work. |
| ||
- delete |
| ||
Thanks for your kind comments! @Blade Runner: That looks like a reasonable alternative! For now I am happy with my solution (but TBH yours seems tighter, tougher and faster, and I have no idea how its doing what its supposed to do ;). Certainly looks like I reinvented the wheel :/. How does it work? -- edit Ah I think I understand it now. You are taking the rotation approach, dont you? Well, mine is less analytic and more pragmatic :) (after all perfectly adjusted to my requirements) |
| ||
in your demo the tiles are the same width as height but in the code it says they are 2:1 twice as wide as high, ?? ALso can you get scrolling to work? |