Advertisement
xeromino

balls

May 18th, 2017
208
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void mouseClicked() {
  2.   for (int i=0; i<noCircles; i++) {
  3.     float x = width/2 + sin(radians(frameCount*speed[i] ) + phase[i])* 200;
  4.     if (dist(x, y[i], mouseX, mouseY) < 50) {
  5.       if (speed[i]>0) { // if the circle is moving, stop it
  6.         speed[i] = 0;
  7.         phase[i] = 0;
  8.       } else {  // if the circle is not moving, restart it
  9.         speed[i] = random(5);
  10.         phase[i] = random(TWO_PI);
  11.       }
  12.     }
  13.   }
  14. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement