Sign in to follow this  

Rotated vs staggered isometric tile selection

This topic is 4338 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have read this article and found it really helpful. I have successfuly drawn a staggered isometric map like this: and have got tile clicking working perfectly using the mouse map method in the above article. However, I am trying to implement now a rotated isometric viewpoint like below: I have managed to draw this but I cannot get tile selection to work at all using the mouse map method. Could anyone offer any help or advice? Many thanks in advance, Garry [Edited by - Garry on January 28, 2006 6:13:51 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi garry. I am writing an isometric game engine atm, and Initially I started out using the rotated method. But I also hit a wall when trying to implement mousemapping. I decided to go for the staggered method and havent had any major problems yet. What is your reason for using the rotated method?

Share this post


Link to post
Share on other sites
Garry,

It shouldn't be necessary to use a mouse mapping method. Your transformation from a regular grid to the isometric grid is simply a rotation and a sheer, so you can do all of the coordinate mapping as a standard matrix transform.

To be honest, I don't know what the actual math would be. So, my first place to check is Google. Searching for "transforming mouse coordinates isometric" gives me Brian Hook's discussion on isometric engines as the first result. This is an excellent article, highly recommended for some fundeamental observations of commercial isometric game engines.

Near the end of his article, he addresses the technical issue of transforming mouse coordinates to map coordinates. Jump to the end of the article for his equations (his graphics are much better than what I could reproduce here).

Share this post


Link to post
Share on other sites

I use the rotated method and was able to hack out a couple of functions to return the tile that the mouse is over.



float yFactor = (cameraCentreY - halfScreenHeight - mouseYPosition) / Tile.HalfHeight;
float xFactor = (cameraCentreX - halfScreenWidth - mouseXPosition / Tile.HalfWidth;

float tiley = (yFactor - xFactor) / 2.0f;

float tilex = (yFactor + xFactor) / 2.0f;



Hopefully it's fairly self explanatory what the variables are. Tile.HalfHeight and Tile.HalfWidth are constants that hare 1/2 tile height and width.

So a final result of tiley = 23.432 and tilex = 10.999 would mean that the mouse was over tile (10,23). Don't round up.


Share this post


Link to post
Share on other sites
Have you looked at the iso article on here that I wrote?

http://www.gamedev.net/reference/articles/article2026.asp

That article deals with adding height to your diamond / rotated maps, but it has all the code in there to help you work out your mouse maps.

Share this post


Link to post
Share on other sites

This topic is 4338 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this