Hello Processors, please help me figure what to do. I want video objects to bounce off the window edges and collide between them. The issue I am having is that I want the objects to have random sizes. this is messing everything up. Thank you for your time
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.move();
video.collide();
video.display();
}
}
void movieEvent(Movie m) {
m.read();
}
class Video {
float rectW, rectH;
float rectSpeedY;
float rectSpeedX = 1;
float rectY = 0;
float rectX = random(15)*50;
float s = random(1);
Video (float w, float h) {
rectW = w;
rectH = h;
}
void move() {
rectY += rectSpeedY;
if (rectY+s + rectH+s > groundY) {
rectY = groundY - rectH*s;
//bounce
rectSpeedY *= -1 ;
} else {
rectSpeedY++;
}
}
void collide() {
}
void display() {
image(myMovie, rectX, rectY, rectW*s, rectH*s);
}
}