How can I make my isometric tile collision detection more accurate, I'm using the Rectangle class from java to detect collisions but because it's a rectangle it overlaps other rectangles which means clicking on a tile has a chance of selecting the tile next to it and I would like to know how to fix that.

  • \$\begingroup\$ I would suggest you to read a bit on linear algebra, and how basis changes work. Then you can find exactly the tile the user selects without using collision algorithms altogether. It sound like this is what you seek. Thus, it is not too hard to implement <code>Point2d getTileCoord(Point2d moiseclick)</code> if you have a static set of tiles in a grid. \$\endgroup\$ Commented Jan 2, 2012 at 10:23

1 Answer 1


First off, as you stated in your question, you should be using a better representing for the bounding box of each collision. Rectangles are (obviously) incorrect.

Why not create your own Diamond class and have each object in your world bound by it? That should provide a better mapping to isometric tiles. As for how to detect if the parallelogram actually contains the point selected, refer to this StackOverflow post: "Parallelogram contains Point".

  • \$\begingroup\$ Are you suggesting I make my own Diamond Class that extends the Point class? I didn't know you could bring points together to form objects? \$\endgroup\$ Commented Dec 15, 2011 at 19:59
  • \$\begingroup\$ Shapes are technically just lines and points in space... \$\endgroup\$
    – dann.dev
    Commented Dec 15, 2011 at 20:10
  • \$\begingroup\$ I know how to draw shapes but I don't know how to make a class of one... \$\endgroup\$ Commented Dec 15, 2011 at 21:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .