Hey, I have update the video sketch since this attempt and now I am even more confused!
- ////// VIDEO ///////////////////////////////////////////
- int maxMovies = 2; // Total number of movies
- int myMoviesIndex = 0; // Initial movie to be displayed
- ////// RAIN ///////////////////////////////////////////
- int rainNum = 100;
- ArrayList rain = new ArrayList();
- ArrayList splash = new ArrayList();
- float current;
- float reseed = random(0, .2);
- videoSketch sketch;
- //rainSketch sketch2;
- void setup() {
- size(1280, 720);
- background(0);
- //instatiate our classes
- sketch = new videoSketch(width, height);
- sketch2 = new rainSketch(width, height);
- }
- void draw() {
- background(0);
- //call the happen function (also called a method) within each sketch
- sketch.happen();
- sketch2.happen();
- }
- public class videoSketch {
- private int w, h;
- Movie[] myMovies;
- void loadMovie() {
- myMovies = new Movie[maxMovies]; //array of movies
- for (int i = 0; i < myMovies.length; i ++ ) {
- println(i);
- myMovies[i] = new Movie(this, i+1 + ".mov");
- myMovies[i].loop();
- myMovies[i].pause();
- }
- }
- void playMovie() {
- myMovies[myMoviesIndex].play();
- image(myMovies[myMoviesIndex], 0, 0); // Displays image
- println(myMovies[myMoviesIndex].time());
- float mt = myMovies[myMoviesIndex].time();
- float md = myMovies[myMoviesIndex].duration();
- if (mt == md) {
- myMovies[myMoviesIndex].pause();
- myMoviesIndex ++;
- if (myMoviesIndex == maxMovies) {
- myMoviesIndex = 0;
- }
- myMovies[myMoviesIndex].jump(0);
- myMovies[myMoviesIndex].play();
- }
- }
- }
- void movieEvent(Movie myMovies) {
- myMovies.read();
- }
- public class rainSketch {
- size(600, 600, P3D);
- colorMode(HSB, 100);
- background(0);
- rain.add(new Rain());
- current = millis();
- void rain() {
- background (0);
- blur(50);
- strokeWeight(9);
- stroke(255, 2, 2);
- line (width/2.0, 0, 100,
- width/2.0, 0, 200 );
- if ((millis()-current)/1>reseed &&
- rain.size()<150)
- {
- rain.add(new Rain());
- float reseed = random(0, .2);
- current = millis();
- }
- for (int i=0 ; i<rain.size() ; i++)
- {
- Rain rainT = (Rain) rain.get(i);
- rainT.calculate();
- rainT.draw();
- if (rainT.position.y>height)
- {
- for (int k = 0 ; k<random(5,10) ; k++)
- {
- splash.add(new Splash(rainT.position.x, height, rainT.position.z));
- }
- rain.remove(i);
- float rand = random(0, 100);
- if (rand>10&&rain.size()<150)
- rain.add(new Rain());
- }
- }
- for (int i=0 ; i<splash.size() ; i++)
- {
- Splash spl = (Splash) splash.get(i);
- spl.calculate();
- spl.draw();
- if (spl.position.y>height)
- splash.remove(i);
- }
- }
- public class Rain
- {
- PVector position, pposition, speed;
- float col;
- public Rain()
- {
- position = new PVector(random(0, width), -500, random(0, 800));
- pposition = position;
- speed = new PVector(0, 0);
- col = random(30, 100);
- }
- void draw()
- {
- stroke(100, col);
- strokeWeight(2);
- line(position.x, position.y, position.z, pposition.x, pposition.y, position.z);
- //ellipse(position.x,position.y,5,5);
- }
- void calculate()
- {
- pposition = new PVector(position.x, position.y);
- gravity();
- }
- void gravity()
- {
- speed.y += .2;
- speed.x += .01;
- position.add(speed);
- }
- }
- public class Splash
- {
- PVector position, speed;
- public Splash(float x, float y, float z)
- {
- float angle = random(PI, TWO_PI);
- float distance = random(1, 5);
- float xx = cos(angle)*distance;
- float yy = sin(angle)*distance;
- position = new PVector(x, y, z);
- speed = new PVector(xx, yy);
- }
- public void draw()
- {
- strokeWeight(1);
- stroke(100, 50);
- fill(100, 100);
- // ellipse(position.x, position.y, 2, 2 );
- point(position.x, position.y, position.z );
- }
- void calculate()
- {
- gravity();
- speed.x*=0.98;
- speed.y*=0.98;
- position.add(speed);
- }
- void gravity()
- {
- speed.y+=.2;
- }
- }