Adjacent Rectangles intersect.
If we have two rectangles, r1 and r2, such that
r1 = new Rectangle(60,60,20,20); r2 = new Rectangle(80,60,20,20);
r1.intersects(r2) returns true; r2.intersects(r1) also returns true.
This doesn't seem quite right to me.
Comments (2)


No, you're entirely incorrect. When I create a new rectangle, the constructor parameters are xposition, yposition, width, and height. If I make a rectangle like so:
Rectangle r1 = new Rectangle(0,0,20,16);
This means that the rectangle will occupy all positions from x = 0 to x = 19 (20 pixels, the width) and y = 0 to y = 15 (16 pixels, the height).
Furthermore, if my game is tiled 20x20, my walls should have a width and height of 20 without intersecting each other.
Can you point me to what graphics library has this illogical practice?
 Log in to comment
Well, they are intersecting!
If the second rectangle would be place at (81, 60) then they wouldn't intersect.
60+20 = 80, which means that they intersect. You need to add +1 to x position of the second triangle, or 1 to the width of the first, for them not to intersect. This is common practice through all graphics libraries.