Drawing on mousePressed with delay.

edited October 2014 in How To...

Hello, I want to create app that repeats mouse movement history while it was pressed. I want the app to repeat the movements.

So far I have this, though it only repeats last or one position, and I want it to repeat 30 steps in this case.

int num = 30;
int [][] records = new int[num][2];

void setup(){
  size(600,600);
  }

void draw(){
  background(0);

  if (mousePressed){
    for(int i=0; i<records.length; i++){
    records [i][0] = mouseX;
    records [i][1] = mouseY;
    }
  }

  else{
    for(int i=0; i<records.length; i++){
    ellipse(records[i][0],records[i][1],20,20);
    }
  }
}

Answers

Sign In or Register to comment.