Advertisement
fosterbl

BallRunner processing - put this in the sketch window

Feb 7th, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1. Ball[] balls;
  2.  
  3. void setup(){
  4.   size(640,480);
  5.   balls = new Ball[10];
  6.   initBalls();
  7. }
  8.  
  9. void initBalls(){
  10.   for(int i = 0; i < balls.length; i++) balls[i] = new Ball();
  11.   //make any of the balls a different type here. Right now they are all type Ball.
  12. }
  13.  
  14. void draw(){
  15.   background(255);
  16.   for(Ball b : balls){
  17.     b.display();
  18.     b.move();
  19.     b.bounce();
  20.   }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement