Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
    
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. –  Paxinum Jan 2 '12 at 10:23
add comment

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".

share|improve this answer
    
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? –  user1048606 Dec 15 '11 at 19:59
    
Shapes are technically just lines and points in space... –  dann.dev Dec 15 '11 at 20:10
    
I know how to draw shapes but I don't know how to make a class of one... –  user1048606 Dec 15 '11 at 21:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.