I need help to make it so that when the square touches a green rectangle it resets to position (20,650)

int x=20;
int y=650;
int w=20;
int h=20;

int c=1;
int d=20;

String a= "";
String b= "Warning: Wormhole detected ahead. Approach with caution.";

float rectX;
float rectY;

float rectA;
float rectB;

float rectC;
float rectD;

float rectE;
float rectF;

float rectG;
float rectH;

float rectWidth;
float rectHeight;


//A Mover object
Mover mover;

void setup() {
  size(800,900);
  mover = new Mover(); 
rectX=100;
rectY=200;

rectWidth=30;
rectHeight=600;

rectA=250;
rectB=350;

rectC=350;
rectD=200;

rectE=420;
rectF=350;

rectG=510;
rectH=200;
}

void draw() {
 
  background(0);
  smooth();
  background(0);
  noStroke();
  fill(255,0,0);
  rect(10,10,785,190);
  filter(BLUR, 6);
  stroke(0);
  fill(255,255,0);
  rect(10,10,780,180);
  
  // Update the location
  mover.update();
  // Display the Mover
  mover.display(); 



 textSize(20);
fill(0);
text(a, 100,50);

fill(25,200,35);
rect(rectX,rectY,rectWidth,rectHeight);
rect(rectA,rectB,rectWidth,rectHeight);
rect(rectC,rectD,rectWidth,rectHeight);
rect(rectE,rectF,rectWidth,rectHeight);
rect(rectG,rectH,rectWidth,rectHeight);

if (x> rectX && x < rectX + rectWidth && y > rectY && y < rectY + rectHeight) {
 x=20;
  y=650;
  } else if (x > rectA && x < rectA + rectWidth && y > rectB && y < rectB + rectHeight) {
    x=20;
  y=650;
  }  else if (x > rectC && x < rectC + rectWidth && y > rectD && y < rectD + rectHeight) {
    x=20;
  y=650;
  }  else if (x > rectE && x < rectE + rectWidth && y > rectF && y < rectF + rectHeight) {
    x=20;
  y=650;
  }  else if (x > rectG && x < rectG + rectWidth && y > rectH && y < rectH + rectHeight) {
    x=20;
  y=650;
  } 

}


class Mover {

  // The Mover tracks location, velocity, and acceleration 
  PVector location;
  PVector velocity;
  PVector acceleration;
  // The Mover's maximum speed
  float topspeed;

  Mover() {
    // Start at (20,650)
    location = new PVector(x,y);
    velocity = new PVector(0,0);
    topspeed = 10;
  }

  void update() {
    
    // Compute a vector that points from location to mouse
    PVector mouse = new PVector(mouseX,mouseY);
    PVector acceleration = PVector.sub(mouse,location);
    // Set magnitude of acceleration
    acceleration.setMag(5);
    
    // Velocity changes according to acceleration
    velocity.add(acceleration);
    // Limit the velocity by topspeed
    velocity.limit(topspeed);
    // Location changes by velocity
    location.add(velocity);
  }

  void display() {
    stroke(255);
    strokeWeight(2);
    fill(127);
    rect(location.x,location.y,20,20);
  }

}

please format your code posting by pasting it into the

</> code button

of the editor header menu ( context name: Preformatted text )
it looks like
```
type or paste code here
```

also can use the ``` manually above and below your code.

thank you.


what are these

if (x> rectX && x < rectX + rectWidth && y > rectY && y < rectY + rectHeight) {

lines supposed to do?
what is x y used for?

Thank you for taking a look. The above code you have a question about is a proximity detection, but I’m struggling with making proximity for the below object.

fill(127);
    rect(location.x,location.y,20,20);

The x and y are just up there temporarily (I was trying to represent locaton.x with x and location.y with y). It didn’t work, but I want it so that if the rectangle’s position is within the green rectangles it will reset to position (20,650). It’s like a maze where if the object touches a wall it resets.