Advertisement
fosterbl

Bubble class Processing

Nov 1st, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. class Bubble{
  2.   int diameter, x, y;
  3.  
  4.   Bubble(int d){
  5.      diameter = d;
  6.      x = (int)(Math.random() * width);
  7.      y = (int)(Math.random() * height);
  8.   }
  9.  
  10.   void display(){
  11.     ellipse(x, y, diameter, diameter);
  12.   }
  13.  
  14.   void ascend(){
  15.     y--;
  16.     x += (int)(Math.random() * 4 - 2);
  17.   }
  18.  
  19.   void top(){
  20.     if( y + diameter <= 0 ){
  21.       y = height + diameter/2;
  22.     }
  23.   }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement