Circles moving randomly and different to each-other + collision

I’ve been trying to understand how the circles flowing from the right to the left can become random instead of being in the same line. the circles enter at random/different times. I’m new to processing and am stuck on this. I’ve also been trying to use the dist() function in order for it to be game over when the mini squares hit the circles but am also struggling with that.


int squareSize = 70;
int squarePositionX = squareSize;
int squarePositionY = squareSize;
int squareVelocityY = 0;
int squareLastGoodY = squarePositionY;
int squareSpeed = 3;

int circleX = 150;

IntList miniSquarePositionsX = new IntList();
IntList miniSquarePositionsY = new IntList();
int miniSquareSpeed = 9;
int miniSquareSize  = 35;

void setup () {
  size (600, 600);
  rectMode(CENTER);
}

void draw () {
  if(keyPressed){
    if(key == 'w' && key != ' '){
      squareVelocityY = -squareSpeed;
    }else
    if(key == 's' && key != ' '){
      squareVelocityY =  squareSpeed;
    }
  }else{
    squareVelocityY = 0;
  }
  
  squarePositionY += squareVelocityY;
  if (squarePositionY >= width - (squareSize * 0.5) || squarePositionY <= (squareSize * 0.5)) {
    squareVelocityY *= -1;
    squarePositionY = squareLastGoodY;
  }else{
    squareLastGoodY = squarePositionY;
  }
  
  for(int i = 0 ; i < miniSquarePositionsX.size(); i++){
    miniSquarePositionsX.set(i, miniSquarePositionsX.get(i) + miniSquareSpeed);
    if(miniSquarePositionsX.get(i) > width){
      miniSquarePositionsX.remove(i);
      miniSquarePositionsY.remove(i);
    }
  }
  background (0);

  fill(100);
  ellipse (circleX, 120, 150, 150);

ellipse (circleX, 290, 150,150);
ellipse (circleX, 490,150,150);

  fill (225);
  rect (squarePositionX, squarePositionY, squareSize, squareSize);
  
  circleX -= 2;
  if (circleX < - 20) {
    circleX = 550;
  }
  for(int i = 0 ; i < miniSquarePositionsX.size(); i++){
    rect(miniSquarePositionsX.get(i), miniSquarePositionsY.get(i), miniSquareSize, miniSquareSize);
  }
}

void keyReleased(){
  if(key == ' '){
    miniSquarePositionsX.append(squarePositionX);
    miniSquarePositionsY.append(squarePositionY);
    println(miniSquarePositionsY);
  }
}