SFML community forums

Help => General => Topic started by: Futochu on February 10, 2015, 07:14:48 am

Title: Selecting tile with mouse on an isometric map
Post by: Futochu on February 10, 2015, 07:14:48 am
Is there an accepted way of determining the tile your mouse cursor is hovering over in an isometric map with varying heights?  It's trivial to map the position of a mouse cursor to a tile if all heights were zero, but I can't for the life of me figure out how to get a tile that has an unknown height.  This is what my map currently looks like (excuse the placeholder graphics). 

http://i.imgur.com/nOLvK37.png (http://i.imgur.com/nOLvK37.png)

I've read about things such as image maps to determine relative positions, but does this work when heights can vary by +/- 512?

Thanks.
Title: Re: Selecting tile with mouse on an isometric map
Post by: eXpl0it3r on February 10, 2015, 08:48:45 am
Well you're drawing tiles somehow and when drawing you have to know their position, as such it shouldn't be hard to map the mouse's position to the tile position.

A useful function for you might also be: window.mapPixelToCoords()
Title: Re: Selecting tile with mouse on an isometric map
Post by: Futochu on February 10, 2015, 09:20:00 am
I was afraid that would be the best answer.  Thanks though