Here you can find the source of rectCollide(final Rectangle a, final Rectangle b)
public static boolean rectCollide(final Rectangle a, final Rectangle b)
//package com.java2s; /* /* w w w .j a va 2s.c o m*/ * Copyright 2012 Samuel Taylor * * This file is part of darkFunction Editor * * darkFunction Editor is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * darkFunction Editor is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with darkFunction Editor. If not, see <http://www.gnu.org/licenses/>. */ import java.awt.Rectangle; public class Main { public static boolean rectCollide(final Rectangle a, final Rectangle b) { if (a.x > b.x + b.width || a.y > b.y + b.height || a.x + a.width < b.x || a.y + a.height < b.y) { return false; } return true; } }