Finding out which tile a mouse click landed in

Posted by Shard on Game Development See other posts from Game Development or by Shard
Published on 2011-06-29T01:54:14Z Indexed on 2011/06/29 8:32 UTC
Read the original article Hit count: 195

Filed under:
|
|

I am working on an icometric grid based game and im having an issue trying to link a mouse click from the user to a tile. I have been able to split the problem into 2 parts which is first finding a rectangle that sourounds a tile, which I have been able to do but the second part of figuring out from the rectangle which tile the click landed in has got me stumped.

Here is an example of a rectangle with tiles on the inside:

Rectangle containing tiles

The rectangle is 70px long and 30px high so if i use an input of say 30x(top)/20y(left) how would I go about determining which tile this fell into?

© Game Development or respective owner

Related posts about algorithm

Related posts about tiles