|
|
    
| I've been wrapped up in some Windows Phone 7 development for a while now (and really still am) but I wanted to go ahead and post the next installment of the Tile Engine Tutorial series as it has been mostly finished for a while.
This time around, we look at converting an X/Y coordinate (in screen terms) into a tile coordinate on the map. This tutorial looks at using the mouse to select tiles on an isometric map. The same technique applies to hexagonal maps as well.
The next installment will look at putting an animated character on the map, and relies on the code developed here to properly position the image as the character moves around the map. That installment should be arriving in the near future, but no absolute promises! 
Check out the tutorial on the Tutorials Page or via the direct link.
|
|
| |
|
New user
Posts: 1
| I remember reading that a Binary shift would work as well, somwhere. Something like
public Point RealToIso(Point original)
{
int ix = original.X;
int iy = original.Y;
Point p = new Point((ix + iy) >> 1, RealWidth - ((RealWidth + iy - ix) >> 1));
return p;
}
// realwidth = width of box;
public Point IsoToReal(Point original)
{
int vx = original.X;
int vy = original.Y;
return new Point(
vx + vy - RealHalfLength,
vx + (length - vy) - RealHalfLength);
}
RealHalfLength is the greater of width or height of the box, divided by 2
Really looking forward to the next part in the series!
Edited by Ian 2011-04-25 12:33 PM
|
|
| |
|
New user
Posts: 1
| The placement of the hilighted tile is out of place when firstY is odd. I am trying to figure out a fix right now. I'll post later if i figure something out. You can see the error if you move the camera down to where the first tile is 0,1. You'll notice that the hilighted tile is off with the grid. |
|
| |
|
    
| You are definitely right about the hilight placement bug when the offset is incorrect... I'm working on a fix for that, though it might take a few days before I have time to work it out. |
|
| |