Isometric Screen View to World View
Posted
by
Sleepy Rhino
on Game Development
See other posts from Game Development
or by Sleepy Rhino
Published on 2012-09-23T12:01:12Z
Indexed on
2012/09/23
15:50 UTC
Read the original article
Hit count: 335
I am having trouble working out the math to transform the screen coordinates to the Grid coordinates.
The code below is how far I have got but it is totally wrong any help or resources to fix this issue would be great, had a complete mind block with this for some reason.
private Point ScreenToIso(int mouseX, int mouseY)
{
int offsetX = WorldBuilder.STARTX;
int offsetY = WorldBuilder.STARTY;
Vector2 startV = new Vector2(offsetX, offsetY);
int mapX = offsetX - mouseX;
int mapY = offsetY - mouseY + (WorldBuilder.tileHeight / 2);
mapY = -1 * (mapY / WorldBuilder.tileHeight);
mapX = (mapX / WorldBuilder.tileHeight) + mapY;
return new Point(mapX, mapY);
}
© Game Development or respective owner