Advertisement
xeromino

bubbles

Jan 5th, 2014
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. ArrayList thingies = new ArrayList();
  2. float limit, r, org_x, org_y;
  3. color bg = #2E2633;
  4. color s = #DCE9BE;
  5.  
  6. void setup() {
  7.  
  8.   size(500, 300);
  9.   background(bg);
  10.  
  11.   org_x = width/4;
  12.   org_y = height/2;
  13. }
  14.  
  15. void draw() {
  16.  
  17.   background(bg);
  18.   if (org_x < width *.75) {
  19.     if (frameCount % 4 == 0) {
  20.       Thingie thingie = new Thingie(org_x);
  21.       thingies.add(thingie);
  22.       org_x += random(8, 12);
  23.     }
  24.   }
  25.  
  26.   for (int i=0; i<thingies.size();i++) {
  27.     Thingie thing = (Thingie) thingies.get(i);
  28.     thing.run();
  29.   }
  30. }
  31.  
  32. void mouseClicked() {
  33.   thingies.clear();
  34.   org_x = width/4;
  35. }
  36. class Thingie {
  37.   float theta, t, x, y, sz;
  38.   float alpha = 255;
  39.  
  40.   Thingie(float _x) {
  41.     x= _x;
  42.     y= height/2 + random(-10, 10);
  43.     sz = int(random(30, 50));
  44.   }
  45.  
  46.   void run() {
  47.     display();
  48.   }
  49.  
  50.   void display() {
  51.  
  52.     fill(s,alpha);
  53.     stroke(s, alpha);
  54.     ellipse(x, y, sz, sz);
  55.     sz -= .35;
  56.     if (sz < 0) alpha = 0;
  57.   }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement