Hello,

new guy here,

I need help with my code, i’m helpless right now now.

i have my 2D isometric map working but, when i want to implemet mouse selection on each tile it calculates wrong

with a help from : https://gamedevelopment.tutsplus.com/tutorials/creating-isometric-worlds-a-primer-for-game-developers--gamedev-6511

mouse calc Code:

```
public void handleMouse(GameMouse mouse, Camera camera)
{
mousePosition = mouse.state.Position;
Point tile = mousePosition;
tile.X += camera.xOffset;
tile.Y += camera.yOffset;
pointingAt = getTileCoordinates(tile);
int temp = 0;
if (pointingAt.X < 0)
{
temp = pointingAt.X;
pointingAt.X = pointingAt.Y;
pointingAt.Y = -temp;
}
if (pointingAt.Y < 0)
{
temp = pointingAt.Y;
pointingAt.Y = pointingAt.X;
pointingAt.X = -temp;
}
}
public Point getTileCoordinates(Point pt){
Point tempPt = new Point(0, 0);
tempPt.X = (int)Math.Floor((decimal)pt.X / (decimal)(tileHeight / 2+32));
tempPt.Y = (int)Math.Floor((decimal)pt.Y / (decimal)(tileHeight / 2+32));
return(tempPt);
}
```

and than i just draw basic tile on top of tile that exists:

```
Tile selectTile = tiles.Find(selectedTile => selectedTile.positionNumber.X == (float)pointingAt.X && selectedTile.positionNumber.Y == (float)pointingAt.Y);
if(selectTile != null) {
int x1 = (int)selectTile.positionNumber.X * tileWidth / 2;
int y1 = (int)selectTile.positionNumber.Y * tileHeight / 2;
int ix1 = x1 - y1;
int iy1 = (x1 + y1) / 2;
Point isoCoords1 = new Point(ix1, iy1);
isoCoords1.X -= camera.xOffset;
isoCoords1.Y -= camera.yOffset;
isoCoords1.Y += 48;
Texture2D renderTexture1 = textureList.Find(texture => texture.type.Equals("basic") && texture.id == 999).getTexture2D();
selectTile.drawTile(isoCoords1, renderTexture1, tileWidth, tileHeight/2);
}
```

when i run the game i’m getting this:

anyone have an idea how to aproach this ?

i will upload full code to GitHub

in zip on github here:

**drawing tile on X,Y solved**

Well i was changing my rendering of the tiles, i switched to Tile[][] from list.

now i have issue with my calculations:

```
int si = (-camera.xOffset - tileWidth) / 64;
int ei = (-camera.xOffset + camera.width + tileWidth) / 64;
int sj = (-camera.yOffset - tileHeight) / 64;
int ej = (-camera.yOffset + camera.height + tileHeight) / 64;
Point start = twoDToIso(new Point(si,sj));
Point end = twoDToIso(new Point(ei, ej));
for (int i = start.X; i < end.X; i++)
{
for (int j = start.Y; j < end.Y; j++)
{ //Draw tiles
```

`

i am lost, and cant sleep becouse of this

Thank You.