This is my first processing project and I am trying to create a game where you avoid randomly moving squares with a square controlled by your mouse. I am having trouble implementing the collision detection. Any help is greatly appreciated.
Here is the code without any collision:
Rectangle rect1;
Rectangle rect2;
Rectangle rect3;
Rectangle rect4;
void setup() {
size(200,200);
rect1 = new Rectangle(color(255,0,0),0,random(200),random(2,5));
rect2 = new Rectangle(color(0,0,255),0,random(200),random(2,5));
rect3 = new Rectangle(color(0,255,0),0,random(200),random(2,5));
rect4 = new Rectangle(color(255,0,255),0,random(200),random(2,5));