Advertisement
xeromino

balls

May 18th, 2017
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  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
Add Comment
Please, Sign In to add comment
Advertisement