# Tile detection on a 2D isometric layered diamond shaped map - What are the math?

by Sanchez Tanguy   Last Updated May 17, 2017 13:13 PM

What are the math for tile detection on a 2D isometric layered diamond shaped map ?

Here is an image of a layer (this is an image from an old folder, I didn't write the display yet for my current project, so it's incomplete but you get the idea) :

A layer

I have them staggered on top of each other. Tile detection could works with a loop but it would take too much time. The basic math for floor tiles doesn't work.

A long time ago I asked this question with an account I'v lost unfortunatly and I had one answer :

• Create an hollow ground

But I never understood what that was and when I type "tile detection hollow ground" on google, I got nothing.

I also found several solution I do not understand the concept :

• Ray scan on neightbours (I know the theory for ray scanning, but neightbours ??? All of that sounds very difficult for me)

• using color mask for a pixel perfect detection (no time to implement such a method)

So, was left the math. And here I'm stuck. I'm looking at my formula 'isometric to screen' conversion(for display), hoping a miracle ha ha :

``````int x = (i - j) * TILE_SIZE_HALF,
y = (i + j) * TILE_SIZE_QUARTER - (layer_id * TILE_SIZE_HALF);
``````

Anyway, is there even a formula able to solve tile detection for such a map ? Am I missing something ?

Pseudo code is welcome. Also, consider you have all informations about the map. Since I use a pseudo MVC code, I have access to all data (tile size, layers number, etc...).

Tags :