How to rewrite function without instancing random()

I have the eye() function and I want to duplicate it several times that every eye look in a different direction (now random number copy to all function instances)

  let x=0;
  let y=0;

function setup() {
  createCanvas(500, 500);
}

function draw() {
  background(0);
  translate(250,250);
  eye();
}

function eye(){
  noStroke();
  fill(255);
  circle(0,0,80);
  
  fill(0);
  circle(x,y,40);
  
   if(frameCount > 30) {
    x = random(30)*cos( random(360) );
    y = random(30)*sin( random(360) );
    frameCount=0;
  }
}

Try changing the seed to a random number every time your function is called: https://p5js.org/reference/#/p5/randomSeed

And another unrelated comment would be to use if(frameCount % 30 == 0) so you wouldn’t have to force frameCount = 0 (although I’m not sure if it really hurts)

Many thanks, but… any example of implementation, please :hushed:

that would be the exact description of using a class instead of a function…