Hey guys! I'm just beginning with Processing, so this is probably something just easy that I still don't understand. Okay now the project: I am trying to make this player that randomize some videos to display them in three different mask (together they form a entire screen) with three different keyboard keys... The masks and, theoretically the random aspect are done, but I really can't figure out how to activate the masks with the keys without using the same array output (without using the same random picked video in all three masks)...And it really sounds complicated, but if someone could help me I would be eternally grateful. (Windows 7/ Processing 2.2.1)
import processing.video.*;
import ddf.minim.*;
//Audio
AudioPlayer player;
Minim minim;//audio context
//
PImage mask1;
PImage mask2;
PImage mask3;
//Array-random
int maxMovies= 4;
int rand = int(random(maxMovies));
Movie[] myMovies=new Movie[maxMovies];
ArrayList<Movie> moviesPlaying = new ArrayList<Movie>();
void setup() {
size (640, 480, P3D);
frameRate(30);
//sound
minim = new Minim(this);
player = minim.loadFile("cocoon.mp3", 2048);
player.play();
//masks
mask1 = loadImage("center.jpg");
mask2 = loadImage("left.jpg");
mask3 = loadImage("right.jpg");
for (int i = 0; i < myMovies.length; i ++ ) {
myMovies[i] = new Movie(this, i+".mov");
}
}
void keyPressed() {
if (key=='a') {
rand = int(random(maxMovies));
moviesPlaying.add(myMovies[rand]);
moviesPlaying.get(moviesPlaying.size()-1).loop();
}
}
void draw() {
background(0);
for (int i = 0; i< moviesPlaying.size (); i++ ) {
Movie m = moviesPlaying.get(i);
if (m.available())
m.read();
m.mask(mask1);
image(m, 0, 0);
}
}
void stop()
{
player.close();
minim.stop();
super.stop();
}