2D Tiled Map [Quicker way of detecting mouse inside of a tile?] *FIXED*

(Buttons to rotate the map)

And holy COW I fixed it!:


		for (int x1 = 0; x1 < TiledMap.getMapWidth(); x1 += x) { // WIDTH
			win1 = x1;
			for (int y1 = 0; y1 < TiledMap.getMapHeight(); y1 += x) { // HEIGHT
				win2 = y1;
				g2d.draw3DRect(40 + x1, 40 + y1, 40, 40, true);
				if (mouseX > win1 && mouseX < win1 + x && mouseY > win2
						&& mouseY < win2 + 40) {
					if ((win1 > 39 && win2 > 39) && (win1 < 722 && win2 < 482)) {
						cont1 = true;
						cont2 = true;
						System.out.println("X: " + win1 + ", Y: " + win2);
					} else {
						cont1 = false;
						cont2 = false;
					}
					if (cont1 && cont2) {
						g2d.setColor(Color.cyan);
						g2d.draw3DRect(x1, y1, 40, 40, true);
						g2d.setColor(Color.red); // fixing all the repeating tiles that were rending (painting them to blend).
						g2d.draw3DRect(x1 + 40 + win1, y1 + 40 + win2, 40, 40,
								true);
					}
				} // end Y
			}
		}

Here’s how it looks now…