Isometric Screen View to World View
- by Sleepy Rhino
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);
}