|
Point in tile isometric diamond map |
Rick
Member #3,572
June 2003
|
Is it possible to find what tile the mouse is in on an isometric diamond shaped map with a calculation instead of having to loop through each tile and figuring it out? Much like a square tile map you can do: [EDIT] I guess if things are easier in a staggered isometric map I'd be open to that also. I have just never worked on those before. ======================================================== |
HoHo
Member #4,534
April 2004
|
use a mouse lookup map I've done it in an Xcom-like engine and it worked rather fine. I'd give you a link to the sources I once attached to a post but it seems like the links are broken and I can't find that post. I can upload it later today if you want to. [edit] Actually I meant this article but the first one can be useful too. This one also has formula for finding the tile coordinates from screen coordinates __________ |
Sirocco
Member #88
April 2000
|
You've got a couple of options depending on the complexity of the map. You can create a lookup table using various methods. Some are more memory efficient than others. There are some techniques you could investigate using rays to trace the route to the 'monitor', which I've used with varying degrees of success. At the end of the day, a lookup table would probably be your best bet. --> |
Rick
Member #3,572
June 2003
|
I've looked at the second article (Out With the Old, In With the New) which shows how to find the tile the mouse is in via a simple calculation, but I'm not sure about the drawing of the diamond tilemap that matches that code. You seem to have to draw the first tile 1/2 way into the top left screen. ======================================================== |
HoHo
Member #4,534
April 2004
|
Quote: I'm not sure about the drawing of the diamond tilemap that matches that code. You seem to have to draw the first tile 1/2 way into the top left screen. I don't understand. The ideas from the second article should work with pretty much anything. I copied them almost directly to my engine that supported diamond shape maps, multiple levels and per-pixel scrolling. Result was something like this: __________ |
Rick
Member #3,572
June 2003
|
Here is the complete code and it doesn't seem to work. I just copied the code on that page and plugged it in. When I clicked the top tile I get mapx = 34, and mapy = 2, which isn't right. I'm expecting 0,0. I must be doing something wrong. [EDIT] [EDIT2] Bascially changed: and it works now. Thanks all.
======================================================== |
Wilson Saunders
Member #5,872
May 2005
|
When I made my Isometric tileing engine I had two grids of tiles the first with no offset and the other offset by 1/2 the width and 1/2 the height. The tiles were bitmaps with magenta 0xff00ff as the non diamond section. So individually the grids would draw a checkered pattern but toggether they draw the full ground. Any to get to your question. You find the which node in each grid the mouse is closest to like: Then you decide which grid tile you are going to use like this Hope this helps ________________________________________________ |
|