# Isometric Mouse Collision?

I’ve been messing around with drawing isometric tiles and I’m a bit stuck on mouse collisions. I found this article on isometric tiles: http://clintbellanger.net/articles/isometric_math/

Here’s my rendering code:

`````` for(int x = 0; x < map.width(); x++){
for(int y = map.height(); y >= 0; y--){
Sprite s = map.getSpriteAt(x, y);

int xa = (x - y) * (s.width / 2);
int ya = (x + y) * (s.height / 2);

Point p = mouseToIsoTile(mx, my, s.width, s.height);
if(p.x != x || p.y != y) screen.renderSprite(s, xa, ya);
}
}
``````

The onTile() methods takes in the mouse x,y coords as well as the sprite width and height.

Here’s the onTile() method:

``````public Point onTile(int xa, int ya, int width, int height){
int x = (xa / (width / 2) + ya / (height / 2)) / 2;
int y = (ya / (height / 2) - (xa / (width/ 2))) / 2;
return new Point(x, y);
}
``````

When I run the code to hide the tile below the mouse I get this:

You can see the hidden tile is somewhat accurate, but it seems off and I cant seem to figure out why.