Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int n=500;
- int x[]=new int[n];
- int y[]=new int[n];
- int velocidad[]=new int[n];
- int diameter[]=new int[n];
- color bola[]=new color[n];
- void setup() {
- size(800, 600);
- for (int i=0; i<n; i++) {
- x[i]=(int)random(width);
- y[i]=(int)random(height);
- velocidad[i]=(int)random(-20,20);
- diameter[i]=(int)random(30,150);
- bola[i]=color(random(255),random(255),random(255),random(50,255));
- }
- noStroke();
- smooth();
- }
- void bolita(int x, int y, color bola, float diameter) {
- fill(bola);
- ellipse(x, y, diameter, diameter);
- }
- void draw() {
- background(0);
- for (int i=0; i<n; i++) {
- bolita(x[i], y[i], bola[i], diameter[i]);
- x[i]+=velocidad[i];
- if (x[i]>width | x[i]<0) {
- velocidad[i]=-velocidad[i];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement