Dropping objects

Hello Processors, thank you for your time. I have an array of object moving on their y axes until a certain “ground” point. It works fine, but when I scale the objects to be different sizes the objects don’t stop exactly where they should. I want to scale randomly and proportionally these objects.

import processing.video.*;
Movie myMovie;

int numVideos = 10;
Video[] videos = new Video[numVideos];

float groundY = 580;

void setup() {
  size (640, 640);
  myMovie = new Movie(this, "fogata.mp4");
  myMovie.loop();
  for (int i = 0; i < numVideos; i++) {
    videos[i] = new Video(4096/10, 2160/10);
  }
}

void draw() {
  background(64);
  stroke(255);
  line(0, groundY, width, groundY);
  //imageMode(CENTER);
  for (Video video : videos) {
    video.drop();
    //video.move();
    //video.collide();
    video.display();
  }
}

void movieEvent(Movie m) {
  m.read();
}
class Video {

  float rectW, rectH;
  float rectSpeedX, rectSpeedY;
  float rectY = 0;
  float rectX = random(15)*50;
  float s = random(2);
  
  Video (float w, float h) {
    rectW = w;
    rectH = h;
  }

  void drop() {
    rectY += rectSpeedY;
    if (rectY + rectH > groundY) {
      rectY = groundY - rectH;
      rectSpeedY = 0;
    } else {
      rectSpeedY= rectSpeedY + 150;
    }
  }

  void display() { 
    scale(s);
    image(myMovie, rectX, rectY, rectW, rectH);
  }
}

fixed

float s = random(1);
  void drop() {
    rectY += rectSpeedY;
    if (rectY+s + rectH+s > groundY) {
      rectY = groundY - rectH*s;
      rectSpeedY = 0;
    } else {
      rectSpeedY= rectSpeedY + 150;
    }
  }

  void display() { 

    image(myMovie, rectX, rectY, rectW*s, rectH*s);
  }

Thanks for sharing your solution, @tefa.

Could you say something about what float s is doing, and why you needed a [0-1] vs a [0-2] random number?

I am randomly changing the image size. When I added the random variable ‘s’ to the drop function the image stopped exactly where I wanted it to stop. Picked random 1 just for aesthetics reasons.