fosterbl

2 Bubble class processing

Jan 31st, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.34 KB | None | 0 0
  1. class Bubble{
  2.   int x, y, d;
  3.   color c;
  4.  
  5.   Bubble(){
  6.     x = (int)(Math.random() * width/2);
  7.     y = height;
  8.     c = (int)(Math.random() * 256);
  9.     d = (int)(Math.random() * 40 + 5);
  10.   }
  11.  
  12.   void ascend(){
  13.     y--;
  14.     x += (int)(Math.random() * 10 - 5);
  15.   }
  16.  
  17.   void display(){
  18.     fill(c);
  19.     ellipse(x, y, d, d);
  20.   }
  21. }
Add Comment
Please, Sign In to add comment