Código fuente:
m[] m1=new m[101];
void setup() {
size(800, 600);
fill(color(0, 255, 0));
noStroke();
for (int i=0; i<=100; i++) {
m1[i]=new m(random(0, width), random(0, height), random(1, 5));
}
}
void draw() {
background(0);
for (int i=0; i<=100; i++) {
m1[i].mover();
m1[i].display();
}
}
class m {
float x=0, y=0, v=0, t=1, r=0;
int i, c;
int[] cc=new int[61];
m(float xx, float yy, float vv) {
x=xx;
y=yy;
v=vv;
t=random(1, 60);
for (i=0; i<=t; i++) {
cc[i]=(int)random(0, 150);
}
}
void mover() {
y=y+v;
if (y>(height+t*5)) {
y=0;
v=random(2, 11);
x=random(0, width);
t=random(1, 60);
for (i=0; i<=t; i++) {
cc[i]=(int)random(0, 150);
}
}
}
void display() {
for (i=0; i<=t; i++) {
fill(0, cc[i], 0);
rect(x, y-5*i, 5, 5);
}
c=(int)random(0, 255);
fill(0, c, 0);
rect(x, y, 5, 5);
}
}
No hay comentarios:
Publicar un comentario