color b = color(40,60,180); color r = color(180,60,40); color g = color(205); void setup(){ size(500,500); background(204); //Setting up the blue squares fill(40,60,180); for(int y=0; y<=500; y+=200){ for(int x=0; x<=500; x+=200){ rect(x,y,100,100); } } //Setting up the red squares fill(180,60,40); for(int y=100; y<=500; y+=200){ for(int x=100; x<=500; x+=200){ rect(x,y,100,100); } } } void draw(){ int a; int x; int w; int d; if(mousePressed){ int s = get (mouseX,mouseY); if(s==b){ //if you clicked a blue square if(mouseX<=100 && mouseY<=100){ fill(180,60,40); rect(0,0,100,100); } } if(s==r){ rect(103,100,100,100); } } }