xxxxxxxxxx
int numWords = 30;
Words[] allWords = new Words[numWords];
float [] x = new float [numWords];
float [] y = new float [numWords];
float [] speed = new float [numWords];
float w, h;
float stopper;
PImage bg;
void setup() {
size(536, 800);
frameRate(10);
w = 20;
h = 20;
reset();
bg = loadImage("MonaLisa.jpg");
for (int index = 0; index<numWords; index++) {
allWords[index] = new Words();
}
noStroke();
}
void draw() {
background(bg);
for (int index = 0; index<numWords; index++) {
allWords[index].move();
allWords[index].display();
saveFrame();
}
}
/*void stopper () {
for (int i = 0; i < numWords; i++) {
text (x[i], y[i], w, h);
y[i] +=speed[i];
if ((y[i] > stopper) && (speed[i] != 0)) {
y[i] = stopper;
speed[i] = 0;
stopper-=h;
}
}
}*/
void reset () {
//stopper = height-h;
x = new float [numWords];
y = new float [numWords];
speed = new float [numWords];
for (int i = 0; i < numWords; i ++) {
x[i] = random(width-w);
y[i] = random(-200);
speed[i] = random(4)+1;
}
}
void keyPressed () {
if (key == 'p') {
numWords++;
reset();
}
}