other exercise

void setup(){
  size(300,300);
 frameRate(30) ;
}

float x=150,y=150,xn=150,yn=150;
void draw(){
  //background(255);
  if(random(0,10)< 5){
  x = x + random(-15,15);
  }
  else{
  y = y + random(-15,15);
  }
  x= round(x/10.)*10;
  y= round(y/10.)*10;
  x= constrain(x,100,200);
  y= constrain(y,100,200);
  line(x,y,xn,yn);
  xn=x;
  yn=y;
}

void mousePressed(){
  x = mouseX;
  y = mouseY;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s