hello! i am creating random alphabet rain at this moment,
but it seems like continuously same position with same alphabets.
I want it to be all random! is there any solution for this problem?
thanks!
String [] data = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",
"L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
Drop[] drops = new Drop[7];
void setup() {
size(640, 640);
textAlign(CENTER);
for (int i = 0; i < drops.length; i++) {
drops[i] = new Drop();
}
}
void draw() {
background(250);
for (int i = 0; i < drops.length; i++) {
drops[i].fall();
drops[i].show();
}
}
class Drop {
float x;
float y;
float len;
float yspeed;
String textHolder = "text";
Drop() {
x = random(width);
y = random(-300, -50);
yspeed = random(1, 5);
textHolder = data[int(random(data.length))];
}
void fall() {
y = y + yspeed;
float grav = map(0, 0, 20, 0, 0.2);
yspeed = yspeed + grav;
if (y > height) {
y = random(1, 5);
yspeed = map(0, 0, 20, 3, 5);
}
}
void show() {
fill(0);
textSize(30);
text(textHolder, x, y, y+len);
}
}