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);
}
}