Advertisement
Nojus_Globys

falling

May 24th, 2023
611
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1.  
  2. float [] X;
  3. float [] Y;
  4. float [] size;
  5. float [] speed;
  6.  
  7. int quantity = 20;
  8.  
  9. void setup () {
  10.     size (1000, 800);
  11.    
  12.     X = new float [quantity];
  13.     Y = new float [quantity];
  14.     size = new float [quantity];
  15.     speed = new float [quantity];
  16.    
  17.     for (int i = 0; i < quantity; ++i){
  18.         X [i] = random (width);
  19.         Y [i] = random (height);
  20.         size [i] = random (width * 0.1);
  21.         speed [i] = random (height * 0.002, height * 0.01);
  22.        
  23.     }
  24. }
  25.  
  26. void draw () {
  27.     background (0);
  28.     for (int i = 0; i < quantity; ++i){
  29.         circle (X[i], Y[i], size [i]);
  30.         Y[i] += speed [i];
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement