ICC
< back to sketch

int i;
int direction;

void setup(){

  size(300,300);
 direction = 1;

}

void loop(){

  background(255,255,0);
 
   
  
  stroke(255,0,0);
  
  rect(150,i,10,10);
  i+=direction;
  
  if(i>299){
    direction = -1;
  
  }
  
    if(i<0){
    direction = 1;
  
  }

}

< back to sketch