SHARE
TWEET

Untitled

a guest Feb 17th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int radius = 20;
  2. PVector previous = new PVector(0,0);
  3.  
  4. void setup() {
  5.  size(512,512);
  6.  frameRate(24);
  7.  pos = new PVector(random(0,width),random(0,height));
  8.  vel = new PVector(-1,10);
  9.  for(int i = 0;i<number;i++) {
  10.   prev[i]=pos;
  11.  }
  12. }
  13.  
  14.  
  15. void draw() {
  16.   background(255);
  17.   if(pos.x>=width-radius||pos.x-radius<=0) {
  18.     vel.x*=-1;
  19.   }
  20.   if(pos.y>=height-radius||pos.y-radius<=0) {
  21.     vel.y*=-1;
  22.   }
  23.   prev[0]=pos;
  24.   for(int i = 2;i<=14;i++) {
  25.    prev[i]=prev[i-1];
  26.    fill(200);
  27.    ellipse(prev[i].x,prev[i].y,2*radius,2*radius);
  28.   }
  29.   fill(0);
  30.   pos.add(vel);
  31.   ellipse(pos.x,pos.y,2*radius,2*radius);
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top