Advertisement
fosterbl

PoopBall processing

Feb 11th, 2020
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3. class PoopBall extends Ball{
  4.   private ArrayList<PoopBall> ballsPooped;
  5.  
  6.   public PoopBall(){
  7.     super();
  8.     setDiameter( 500 );
  9.     ballsPooped = new ArrayList<PoopBall>();
  10.   }
  11.  
  12.   public void move(){
  13.     super.move();
  14.     if( millis() % 1000 > 0 && millis() % 1000 < 20){
  15.       setDiameter( getDiameter() / 2 );
  16.       PoopBall b = new PoopBall();
  17.       b.setDiameter( getDiameter() );
  18.       b.setColor( getColor() );
  19.       ballsPooped.add( b );
  20.     }
  21.   }
  22.  
  23.   public void display(){
  24.     super.display();
  25.     for( Ball b : ballsPooped ){
  26.       b.display();
  27.       b.move();
  28.       b.bounce();
  29.     }
  30.   }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement